Problems with closeField
Frank D. Engel, Jr.
fde101 at fjrhome.net
Tue Sep 14 09:25:10 EDT 2004
On Sep 14, 2004, at 7:39 AM, JonathanC at ag.nsw.gov.au wrote:
> on keydown k
> if charToNum(k) is among the words of "3 8 9 13 28 29 30 31"
> then pass keyDown
> put k into selection
> end keydown
>
> Typing into the field produces completely normal behaviour: arrowkeys,
> the
> deletekey and backspace key are passed, and everything else is handled
> by
> the line "put k into selection". But when you click out of the field,
> NO
> closeField message is sent.
The arrow keys, delete key, and backspace key are non-printable
characters. They will never be sent via keyDown anyway, they trigger
their own messages instead. You could likely trap them with
rawKeyDown, but it might be better to just ignore them -- that is what
this code will do anyway.
If the code says to "put k into selection", why not just "pass
keyDown"? Then there is no reason for this handler to begin with? I
will assume that this is just an example to demonstrate a problem you
are having elsewhere with your code, could you be more specific about
what you hope to accomplish by trapping the keys here?
If you really want to do this, then an example of a rewrite might be:
on openField
put empty
set the modified of me to false
end openField
on keyDown k
put k into selection
set the modified of me to true
end keyDown
on closeField
put "Field changed."
end closeField
on exitField
if the modified of me then put "Field changed."
end exitField
___________________________________________________________
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
More information about the use-livecode
mailing list