Why no closeField messages sent?

J. Landman Gay jacque at hyperactivesw.com
Thu Jan 13 12:59:28 EST 2005


On 1/13/05 7:41 AM, Michael D Mays wrote:

> I see that now.:) RTM, right?
> 
> I was thrown off by the use of "focus"
> ->
> Sent to a field when the focus is being removed from that field and the 
> field's content has changed.
> <-
> and the focus command. In my mind the user selects and types; the 
> programer shifts focus. In fact the focus does change when the user 
> selects a field. But also the focus can change without any user 
> interaction.
> 
> In fact a put into the fld can stifle the closeField message. Make a 
> card with two flds. In fld 1
> 
>  on keyDown theKey
>   if theKey is "r" then
>    put " rule " after fld 1
>    exit keyDown
> else
>  pass keyDown
> end if
> end keyDown
> 
> In the card's script trap the closeField message
> 
> on closeField
>   beep
> end closeField
> 
> Now type 'dogsr<tab>' (where <tab> is the tab key).
> 
> No beep even though the user has clicked and typed in the field.
> 
> But you can type 'dogsrtheworld<tab>' and get a closeField to fire off.
> 
> I understand the compatibility problems with HyperCard and now in turn 
> Revolution, but shouldn't there be a fieldTouched and/or fieldDirtied 
> message?

The keydown message doesn't catch most of the control keys or other 
non-alphanumeric keypresses. If you want to catch those, use rawKeyDown 
instead. Or, for this particular instance, you could just use a tabKey 
handler to catch the tab. (Note that Macs don't send any keypress info 
if you depress the Cmd key without a second key modifier. The same is 
true for some others; option and shift, I think.)

The reason it works with 'dogsr<tab>' is because the string contains 
non-tab characters that do get caught by a keydown handler.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list