Page 1 of 1

Messaging of arrow key

Posted: Tue Aug 28, 2012 3:57 pm
by rbrucep
I'm having trouble getting the expected behavior of arrowkey.
Goal: interrupt the card advance behavior so I can run it through code in next/previous buttons that decides whether to save user data. Do this while preserving editing feature in text fields

I'm trying to use a front script or stack script
If I put the on arrowkey in a front script, I need to let the text field 'keep' the arrow key. I attempt this using
put the long name of the focusedObject into holder to see if user is in such a field
This works fine, but when I attempt
pass "arrowkey" nothing happens; the text object never gets the message and the arrows fail
I have worked around this using my own code to move the selection point laterally [though not vertically], but its not the way I would like to go.

When I put the arrowKey function in the STACK script, it indeed intercepts the arrowkey message--but it does so before the text field in which the user is typing. That makes partial sense, but I'm not sure why the arrowkey behavior was not handled/allowed in the text field prior.

When I put the arrowkey function on the text field, it does nothing when the field is editable, which seems fair, but means I can't stop the message from reaching the stack script, which will somehow stop it from reaching the FIELD, where it was supposed to have started ;)

tl;dr: Any clever way to intercept arrowkey with regard to its card-advancing function (I would prefer disable rather than kill) while still permitting its direct function in editable text fields?

Thanks
Bruce

Re: Messaging of arrow key

Posted: Tue Aug 28, 2012 4:50 pm
by Klaus
Hi Bruce,

1. welcome to the forum
2. try this in the stackscript, just tested and works :D

Code: Select all

on arrowkey tKey
  if the target begins with "field" then
    pass arrowkey
  else
    ## do your ARROWKEY stuff here
  end if
end arrowkey
No need for a special "arrowkey" script in the field(s).
Can of course be refined to check if the target is not locked etc...


Best

Klaus

Re: Messaging of arrow key

Posted: Thu Aug 30, 2012 7:05 pm
by rbrucep
Klaus:
Thanks a million. I'll give it a try. I'd done a number of combinations of using front script, stack, and field, but this looks like a different one.

Sorry to be so slow in getting back; teaching classes ;)
Bruce

Re: Messaging of arrow key

Posted: Fri Aug 31, 2012 12:50 am
by rbrucep
Klaus:
I wanted to finish the thought. The code works perfectly. In retrospect, it's possible some of my failure was that I experimented with a front script and may have failed to unhook it.

Thanks for your fast and right-on-the-money suggestion!
Bruce

Re: Messaging of arrow key

Posted: Fri Aug 31, 2012 10:33 am
by Klaus
Hi Bruce,

my pleasure :)


Best

Klaus