Page 1 of 1

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

Posted: Sun May 31, 2015 5:47 pm
by mikemc
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

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

Posted: Sun May 31, 2015 6:17 pm
by Martin Koob
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

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

Posted: Sun May 31, 2015 6:33 pm
by SparkOut
set the autoTab of the field to true and that will move the focus to the next layered object that can take focus.

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

Posted: Sun May 31, 2015 6:34 pm
by mikemc
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

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

Posted: Sun May 31, 2015 6:35 pm
by mikemc
still new how do i set the auto tab

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

Posted: Sun May 31, 2015 6:41 pm
by SparkOut
In the property inspector, tick the box with words "Tab on Return" or by script
set the autoTab of field "fieldname" to true

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

Posted: Sun May 31, 2015 6:53 pm
by mikemc
Thanks that was so easy I don't know why I didn't think of it best regards :D

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

Posted: Sun May 31, 2015 7:17 pm
by mikemc
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:

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

Posted: Sun May 31, 2015 7:57 pm
by SparkOut
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

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

Posted: Sun May 31, 2015 8:09 pm
by mikemc
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

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

Posted: Sun May 31, 2015 10:11 pm
by SparkOut
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.

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

Posted: Mon Jun 01, 2015 12:20 am
by mikemc
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

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

Posted: Mon Jun 01, 2015 12:25 am
by mikemc
Found the layer hurray! :D good night