Tab order through controls

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Tab order through controls

Post by AlessioForconi » Fri Apr 03, 2015 7:38 pm

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
Last edited by AlessioForconi on Sat Apr 04, 2015 9:49 am, edited 1 time in total.

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Tabo order through controls

Post by SparkOut » 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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Tabo order through controls

Post by dunbarx » Fri Apr 03, 2015 10:39 pm

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

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Tab order through controls

Post by AlessioForconi » Sat Apr 04, 2015 9:54 am

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.

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Tab order through controls

Post by SparkOut » Sat Apr 04, 2015 12:59 pm

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).
Attachments
tab_order_diversion.livecode.zip
(1.33 KiB) Downloaded 255 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tab order through controls

Post by jacque » Sat Apr 04, 2015 5:09 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Tabo order through controls

Post by aetaylorBUSBnWt » Fri Sep 30, 2022 11:43 am

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.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tab order through controls

Post by Klaus » Fri Sep 30, 2022 12:19 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Tab order through controls

Post by dunbarx » 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

cpuandnet
Posts: 32
Joined: Thu Jan 17, 2019 6:43 am

Re: Tab order through controls

Post by cpuandnet » Fri Sep 30, 2022 4:46 pm

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

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Tab order through controls

Post by aetaylorBUSBnWt » Fri Sep 30, 2022 7:42 pm

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!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tab order through controls

Post by Klaus » 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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tab order through controls

Post by jacque » Fri Sep 30, 2022 8:01 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Tab order through controls

Post by aetaylorBUSBnWt » 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!

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Tab order through controls

Post by SparkOut » Fri Sep 30, 2022 8:28 pm

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

Post Reply