Reputation: 338
I allow the user to use the Tab key to navigate through the form.
I have the form like this...
This is the tab order that I need...
I set the layer number (in the Property Inspector window) to the following...
When I run this form, username is focused. When I press tab, it goes to the password. When I press tab again, it goes back to the Username (not the buttons).
I tried to add code to the password textbox to force focusing the button.
on tabKey
focus on button "logIn"
end tabKey
But I got an error...
" focus: not a valid control "
I found no proper solution around the web. How to achieve this?
In other languages, it is easier to do this.
EDIT: I found this zip file that contains the livecode sample file from livecode forum that shows about hilite the button. This is not the real solution of the problem because it is not really focusing the button but it is changing the color of the button that looks like its active. When I press spacebar while the button is hilite, it does nothing.
Upvotes: 0
Views: 671
Reputation: 29
In the tools > project browser, order your elements from top down in the order you want to tab through.
Upvotes: 0
Reputation: 756
OK. Make two fields on a new card, and then two buttons. As Jacque mentioned, make sure the traversalOn of each button is set.Try this in the card script:
on tabkey
put the layer of the target into tLayer
put the name of the target into tName
put tname
if tName contains "button" then
set the hilite of the target to "false"
end if
if tLayer = the number of controls then focus on control 1
else
focus on control (tLayer + 1)
if the name of control (tLayer + 1) contains "button" then set the hilite of control (tLayer + 1) to "true"
end if
end tab key
As you tab you will see action at each control.
Upvotes: -1
Reputation: 756
"focus" is not a particularly useful term for a button. When you focus on a field, you are "hiliting" that field, and placing the cursor after its text, if any.
But what does it mean to "focus" on a button? Do you want to hilite that button, or in some other way bring attention to it? If so, when tabbing out of the password field, you will want to set some property of the button, but probably not focus on it.
Upvotes: -1
Reputation: 416
Set the traversalOn of the button to true. This allows the behavior you want. Note that Macs do not support button traversal by default but it will work on Windows.
Upvotes: 1