"on enterKey" not working

Kay C Lan lan.kc.macmail at gmail.com
Sun Oct 14 20:36:19 EDT 2007


On 10/15/07, Paul Gabel <paulgabel at comcast.net> wrote:
>
>  The problem isn't default buttons, because I don't have any
> set on the card I'm experimenting on.


Well maybe you should have just 1.

I'm on the verge of abandoning "on enterKey," but if anyone has any
> more suggestions I'd love to hear them. Thank you again.


Here's an option:

In all your fields/buttons, except the one in question, end the script with:

focus on btn "theOneImTryingToFocusOn"

For fields you'll need to handle 'on returnInField', 'on enterInField' and
'on tabKey' to make sure that focus always goes to the button.

Note that this approach may cause confusion if you have multiple fields as
most people expect that once you tab/enter/return out of a field the
Insertion Point will move to the next field.

I checked the above by placing one defaultButton on a card and making it
invisible.  In the couple of fields and buttons on the card I ended their
scripts with the above ' focus on' script. In each case tab/enter/return in
field did what it was suppose to do and then focus was 'lost' - not on or in
any visible object on the card.
Pressing the Enter or Return key would then activate the script in the
invisible defaultButton, which simply beeped and bought a dialog box telling
me the key I'd pressed.

Note that the defaultButton's only contained a 'on mouseUp' script. As noted
before, when a defaultButton has focus and you press Enter or Return a
mouseUp message is sent to the defaultButton.

HTH



More information about the use-livecode mailing list