Page 1 of 2

Tab order through controls

Posted: Fri Apr 03, 2015 7:38 pm
by AlessioForconi
Hi everybody

I'm trying to find a way to move from one control to high with the tab key, excluding some checks and by including others.
Is there a way to do this in Livecode?

Thank You

Re: Tabo order through controls

Posted: Fri Apr 03, 2015 10:23 pm
by SparkOut
Tab order is set by the layer of the control in LiveCode. Look in the property inspector and will see you can bring the object nearer the top or bottom. pressing tab will move from bottom to top.

Re: Tabo order through controls

Posted: Fri Apr 03, 2015 10:39 pm
by dunbarx
Hi.
'm trying to find a way to move from one control to high with the tab key, excluding some checks and by including others
What Sparkout said, but, that said, I have no idea what you are trying to do. Can you explain further?

Craig Newman

Re: Tab order through controls

Posted: Sat Apr 04, 2015 9:54 am
by AlessioForconi
What I would do is to go from one text box to another using the tab key to finish on the button "Insert".
But since I also have other controls on the card to be used are under certain conditions these should be excluded from the cycle of the tab.

Thank You.

Re: Tab order through controls

Posted: Sat Apr 04, 2015 12:59 pm
by SparkOut
This can get very messy very quickly but you can divert the next destination for a tab by intercepting the on tabKey message and determining what to do. A basic sample stack is attached. This is very likely to be more headache than it's worth. You could try and make things more robust and generic by setting custom properties on each object for the next focus object and completely remove the tab order control from LiveCode. But that might be difficult to maintain, unless you have limited number of objects which never change. I believe some rethinking of your user interface would mean you don't have to deal with the problem in this manner. (eg, when you hilite button 1 of a radio group, a group of controls is hidden or disabled. when you hilite button 2 of the radio group, it shows or enables the other group).

Re: Tab order through controls

Posted: Sat Apr 04, 2015 5:09 pm
by jacque
AlessioForconi wrote:What I would do is to go from one text box to another using the tab key to finish on the button "Insert".
But since I also have other controls on the card to be used are under certain conditions these should be excluded from the cycle of the tab.
If you are on Windows and the objects you want to skip are buttons, then you can turn off the traversalon property of those buttons and they will be skipped. Macs don't focus on buttons normally so this is usually a Windows-only issue.

If the controls you want to skip are other fields then you'll need to use one of the workarounds suggested.

Re: Tabo order through controls

Posted: Fri Sep 30, 2022 11:43 am
by aetaylorBUSBnWt
SparkOut wrote:
Fri Apr 03, 2015 10:23 pm
Tab order is set by the layer of the control in LiveCode. Look in the property inspector and will see you can bring the object nearer the top or bottom. pressing tab will move from bottom to top.
As a complete beginner, how to "set the layer of the control" is a total mystery. Don't even know what a Layer is!

So eventually I found that after bringing up the Property inspector on a field, in the "Positions" tab of that window,
DOWN AT THE BOTTOM IS THE LAYER ENTRY. You can type a number into that field.
I clicked on each field in the order I wanted and typed in an increasing number.
When a user is tabbing, Livecode skips any field that the user can't type into.

Since everything else in that pane is related to graphical position and size of the field on the Card, not where I would have looked.

But at least now the next person looking to set Tab Order of fields knows where to look for the "Layer" property of the field - wherever it gets moved next.

Additional stuff about "Layer". When going through the Property window of a Card or Stack (possibly others, I don't know), That little button on the upper right whose Tool tip says "Inspect", well once you get into seeing the fields, buttons, etc, then the number you see after each item - THAT IS THE LAYER NUMBER! It changes whenever you change the layer number in the property of a field.

Re: Tab order through controls

Posted: Fri Sep 30, 2022 12:19 pm
by Klaus
Why not take a look into the DICTIONARY? 8)
It is definitively better than its reputation and explains the LAYER property quite well.
And it even explains how it will affect the taborder of controls.

Re: Tab order through controls

Posted: Fri Sep 30, 2022 3:57 pm
by dunbarx
It is true that fields, assuming a few properties are correctly set, will gain focus in layer order. That is built in, if desired, as an aide to common user expectations.

It is possible, under script control using either the "tabKey", "arrowKey" , or in fact any other message, to pass focus to any control in any order. So you can move from field to button to image to whatever.

Is that what you need to do? Write back if so. You can even have multiple focus ordering on the same card (or even between cards) if you need to.

Craig

Re: Tab order through controls

Posted: Fri Sep 30, 2022 4:46 pm
by cpuandnet
One can also use the project browser to click and drag the controls up and down on the card to the desired tab order. It is a lot easier then having to click on each control and enter a layer number.

Tim

Re: Tab order through controls

Posted: Fri Sep 30, 2022 7:42 pm
by aetaylorBUSBnWt
dunbarx wrote:
Fri Sep 30, 2022 3:57 pm
It is true that fields, assuming a few properties are correctly set, will gain focus in layer order. That is built in, if desired, as an aide to common user expectations.

It is possible, under script control using either the "tabKey", "arrowKey" , or in fact any other message, to pass focus to any control in any order. So you can move from field to button to image to whatever.

Is that what you need to do? Write back if so. You can even have multiple focus ordering on the same card (or even between cards) if you need to.

Craig
I have been trying to use tabKey to move onto the next control when either a return or enter key is pressed.
I really do mean "just the next control" - don't want to have to know what that control is, just let the normal mechanism that reacts to tabKey do its thing.

I have tried:

on returnInField
pass tabkey //this is an compiler error, so stopped that quickly
send "tabKey" //also no good
send "tabKey" to me in 0.1 seconds //no good
dispatch "tabKey" to me //no good
end returnInField

So how does one send the tabKey message and actually get it to move to the next control??

Yes I know I have to write a separate handler for enterInField.

Thanks!

Re: Tab order through controls

Posted: Fri Sep 30, 2022 7:58 pm
by Klaus
This will do, the field has to have its AUTOTAB property to true:

Code: Select all

on returnInField
    type TAB
end returnInField

Re: Tab order through controls

Posted: Fri Sep 30, 2022 8:01 pm
by jacque
The behavior is automatic if you set the autoTab property of each field. The fields must be in the correct order if you want sequential tabbing.

Re: Tab order through controls

Posted: Fri Sep 30, 2022 8:19 pm
by aetaylorBUSBnWt
Klaus wrote:
Fri Sep 30, 2022 7:58 pm
This will do, the field has to have its AUTOTAB property to true:

Code: Select all

on returnInField
    type TAB
end returnInField
ACK!

Sometimes I can't find the simplest things.

Thanks!

Re: Tab order through controls

Posted: Fri Sep 30, 2022 8:28 pm
by SparkOut
aetaylorBUSBnWt wrote:
Fri Sep 30, 2022 8:19 pm
Klaus wrote:
Fri Sep 30, 2022 7:58 pm
This will do, the field has to have its AUTOTAB property to true:

Code: Select all

on returnInField
    type TAB
end returnInField
ACK!

Sometimes I can't find the simplest things.

Thanks!
much simpler is what Jwack said.

Just set the autotab property to true, no need for additional handlers