Trapping for Return, Enter, Escape, and Delete
Sarah Reichelt
sarah.reichelt at gmail.com
Sun Jul 26 20:45:04 EDT 2009
On Mon, Jul 27, 2009 at 10:36 AM, Bill Vlahos<bvlahos at mac.com> wrote:
> This works on my MacBook Pro but I don't know how general a solution it is
> for other Macs, Windows, or Linux.
>
> on rawKeyUp keyCode
> if keyCode = 65293 or keyCode = 65421 then send mouseUp to button "Select"
> -- Return or Enter
> if keyCode = 65307 then send mouseUp to button "Cancel" -- Escape
> if keycode = 65288 then send mouseUp to button "Clear" -- Delete
> end rawKeyUp
>
> I'm not trying to trap for keystrokes in a field as there is no field only
> several buttons.
>
> Is this a good general approach or is there a better way?
This looks fine although I am not 100% sure that the key codes are the
same in every platform.
However one crucial thing you must do is add a "pass rawKeyUp" line
for when you have not trapped the key. Otherwise none of the other
keys will ever work.
I guess if you have no fields this is not such an issue but no
keyboard shortcuts would work either I expect.
on rawKeyUp keyCode
if keyCode = 65293 or keyCode = 65421 then
send mouseUp to button "Select" -- Return or Enter
else if keyCode = 65307 then
send mouseUp to button "Cancel" -- Escape
else if keycode = 65288 then
send mouseUp to button "Clear" -- Delete
else
pass rawKeyUp
end if
end rawKeyUp
Cheers,
Sarah
More information about the use-livecode
mailing list