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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Tab order through controls

Post by Klaus » Fri Sep 30, 2022 8:36 pm

SparkOut wrote:
Fri Sep 30, 2022 8:28 pm
Just set the autotab property to true, no need for additional handlers
But then it depends on the number of visible lines in the field until a RETURN in the field "tabs" to the next control!
Know what I mean? See attached screenshot, I could add a couple of RETURNS to the field until it wnet to the next control with AUTOTAB = true!
Bildschirmfoto 2022-09-30 um 21.32.39.png
Bildschirmfoto 2022-09-30 um 21.32.39.png (11.05 KiB) Viewed 1784 times
This li'l sucker will execute immediatley with the first RETURN:

Code: Select all

on returnInField
    type TAB
end returnInField
:)

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

Re: Tab order through controls

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

Aha, yes, I have always used autotab with a single line field. It doesn't really make sense to me have a multi-line field with autotab set.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Tab order through controls

Post by Klaus » Fri Sep 30, 2022 9:54 pm

SparkOut wrote:
Fri Sep 30, 2022 8:56 pm
It doesn't really make sense to me have a multi-line field with autotab set.
TRUE! :-D
I only wanted to add this for the sake of completeness.

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 11:03 pm

SparkOut wrote:
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
Granted that is the simplest, but I am also doing additional field validation checking at that time.
I have done that implementation in the "on tabKey" handler, so it seemed simplest to send everything to one handler for validation.
Yes, I could turn on the "Tab on Return" property found under the Basic tab for the Field properties and then I would have different code in the enterInField and returnInField handlers, because I still need to do the validation.

Some of these questions are to get you experts to expand upon your answers because they don't immediately make sense to us beginners.(or me with marblehead).
// I have the following routines on the Card containing the fields of interest
// so that I don't have to duplicate them for all the date fields.
//Create a custom property called "isDate" whose value is 1 for DATE fields
//Then the following will check the date value when exiting the field.

on tabKey
if target is not empty and the isDate of the target is 1 then
if validDate() then
pass tabKey //allow to leave if date valid
end if
else
pass tabKey //allow to leave if field empty
end if
end tabKey

on enterInField
if the isDate of the target is 1 then
type TAB //go to date validator
else
pass enterInField //not a date field
end if
end enterInField

on returnInField
if the isDate of the target is 1 then
type TAB //go to date validator
else
pass returnInField //not a date field
end if
end returnInField

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:24 pm

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.

OK, possibly things have changed by October 2022.
I believe you now do this with the Project Browser.
You open up the Card you are interested in and then you can drag the fields up and down to change their order in card's list of fields. That changes the Layer number for the fields based on where you leave the field in the list.
You can still visit each Field's property inspector and change the Layer value under the Position tab.

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 133
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: Tab order through controls

Post by bobcole » Sun Oct 02, 2022 11:43 pm

Jacque mentioned the traversalOn property in a previous post.
by jacque » Sat Apr 04, 2015 11:09 am
...turn off the traversalon property...
I think this good comment needs reinforcement regarding fields.

First, arrange fields in the Project Browser to the order desired (so the fields' layers follow sequentially). The tab key will move the focus to the next field.
Second, for any other fields that shouldn't receive focus, set the other fields' traversalOn property to false by clicking off the "Focus with Keyboard" box in the property inspector or use this code:

Code: Select all

set the traversalOn of field "tField" to false
See the "traversalOn" entry in the Dictionary for more information regarding groups and other controls. According to the Dictionary, the stack's "lookAndFeel" property plays a role in this story, too.

According to the Dictionary, the "autoTab" property: specifies whether pressing Return (or Enter) moves to the next field.

I hope that provides some clarity rather than confusion,
Bob

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Tab order through controls

Post by stam » Mon Oct 03, 2022 12:24 pm

bobcole wrote:
Sun Oct 02, 2022 11:43 pm
According to the Dictionary, the "autoTab" property: specifies whether pressing Return (or Enter) moves to the next field.
and in the IDE the tickbox 'tab on return' in a fields property inspect sets or clears the autoTab property...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”