Upon enter in a fld just leave number and move to next fld

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

Post Reply
mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Upon enter in a fld just leave number and move to next fld

Post by mikemc » Sun May 31, 2015 5:47 pm

I would like to avoid putting multiple numbers in the contents of a field as this hangs up my calculations.
After you put a number in a field I would like the enter key to leave the number and move to the next field.
I already have this code for rounding in most of my fields and don't want to mess with its functioning
onclosefield
put trunc(me) into me
end closefield

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Upon enter in a fld just leave number and move to next f

Post by Martin Koob » Sun May 31, 2015 6:17 pm

You can use focus to move to the next field. I have it so that you move to the next field or if there is no next field then move back to the first field. You could set this as a behaviour for all your fields.

Code: Select all

on enterInField
   if there is a field (the number of me +1) then
      focus on field (the number of me +1)
   else 
      focus on field 1
   end if
end enterInField

on returnInField
   if there is a field (the number of me +1) then
      focus on field (the number of me +1)
   else 
      focus on field 1
   end if
end returnInField

on closefield
   put trunc(me) into me
end close field
Martin

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

Re: Upon enter in a fld just leave number and move to next f

Post by SparkOut » Sun May 31, 2015 6:33 pm

set the autoTab of the field to true and that will move the focus to the next layered object that can take focus.

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Sun May 31, 2015 6:34 pm

I tried the script in the field but still had the problem with the contents and upon enter
I did not move to the next fld maybe I missed something

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Sun May 31, 2015 6:35 pm

still new how do i set the auto tab

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

Re: Upon enter in a fld just leave number and move to next f

Post by SparkOut » Sun May 31, 2015 6:41 pm

In the property inspector, tick the box with words "Tab on Return" or by script
set the autoTab of field "fieldname" to true

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Sun May 31, 2015 6:53 pm

Thanks that was so easy I don't know why I didn't think of it best regards :D

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Sun May 31, 2015 7:17 pm

a strange thing is happening when i set the autoTab sometimes it jumps to a previous field when I hit enter or even
executes a button or jumps to a new card. I guess it wasn't as simple as I thought :cry:

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

Re: Upon enter in a fld just leave number and move to next f

Post by SparkOut » Sun May 31, 2015 7:57 pm

When you hit return with autoTab set, the focus will move to the next control that can take focus, which is determined by the layer. If it is doing something else after checking the tab order by layer number, such as going to another card, then there is some script making it happen. Do you have any navigation scripts in any groups or the card? If so, you will have to try debugging to determine what is triggering the navigation handler.
If not, I can only think of navigationArrows doing something, either by mistake or sticking keyboard keys

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Sun May 31, 2015 8:09 pm

With the autoTab checked is there a way to tell it what field to focus on next? As my layers are not in the order I want.
I also have next and previous buttons so they must be somehow flipping to the next card after enter is pressed several times

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

Re: Upon enter in a fld just leave number and move to next f

Post by SparkOut » Sun May 31, 2015 10:11 pm

You have to set the layer number to be the order in which controls take focus on tabbing (or autotabbing). You can move an object's layer in the property inspector, or by script
set the layer of field "field1" to 1
You need to be very careful with grouped controls not to move an object out of the group. Look up relayerGroupedControls to see more explanation.
But the layer is setting the tab order at present, which is focussing on the navigation buttons, so pressing the enter key will make that navigation. You can exclude the buttons from the tab order by setting the traversalOn property to false.

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Mon Jun 01, 2015 12:20 am

I must be getting tired I can't find where to change the layer of a field in the property inspector
and I can't find traversalOn property to set it to false for a button
I'll look at it tomorrow maybe you can narrow my search Thanks

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Upon enter in a fld just leave number and move to next f

Post by mikemc » Mon Jun 01, 2015 12:25 am

Found the layer hurray! :D good night

Post Reply