Default button behavior

Devin Asay devin_asay at byu.edu
Tue Mar 20 13:05:02 EDT 2007


On Mar 20, 2007, at 9:48 AM, Len Morgan wrote:

> In my little authorization stack, I've to two fields and two  
> buttons. (Username, password, Login and Cancel).  The Login button  
> has the default property set to true.  The problem is when I tab  
> out of the password field, it skips over the Login button and makes  
> the Cancel button the default (indicated by the ring around the  
> button text).  I'd like the user to be able to enter a username,  
> press Tab, enter a password, press Tab, then hit Return to log in.   
> What's happening now is the program closes after the second Tab and  
> Return because Cancel becomes the default.  What am I doing wrong?

Len,

The controls are probably in the wrong order. Check the layer  
property for all your controls; that will determine the tab order.  
They should be in this order:

field "username" -- layer 1
field "password" -- layer 2
button "login"   -- layer 3
button "cancel"  -- layer 4

You also need to make sure that the traversalOn property is true for  
all controls you want to tab to (see the property inspector; it's  
labeled "Focus with keyboard".)

BTW, you could save a keystroke by adding  returnInField and  
enterInField handlers to the password field:

on returnInField
   click at the loc of btn "login"
end returnInField

on enterInField
   click at the loc of btn "login"
end enterInField

This should not interfere with tabbing.

HTH

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list