Page 1 of 1
Control Enter Key action
Posted: Fri Mar 18, 2022 6:31 pm
by trags3
Hi I have a field that I need to have the user enter a word or two in a field. When the ENTER or RETURN key is pressed I don't want to add another line, I want to focus on another field. I either need to automatically tab to the next field. I do not want another line to be put in the active field. I know this must be possible but can't figure it out.
Tom
Re: Control Enter Key action
Posted: Fri Mar 18, 2022 6:39 pm
by stam
Hi Tom
it's very simple - in the field's property inspector set the "
tab on return" property to true
if you need more complex actions you can trap the
rawKeyDown message, but that's not needed if you just want to tab to next field.
If wanting to script it, it would look like this in the field's script (obviously if you have many fields you'd like this to apply to, store in in a button script or a substack script and assign it as a behaviour to the fields you want it to apply to):
Code: Select all
on rawKeyDown pKeyCode
if pKeyCode = 65293 or pKeyCode = 65421 then -- keyCodes for RETURN and ENTER respectively
// do some stuff
type tab
else
pass rawKeyDown -- don't forget this bit or nothing will type ;)
end if
end rawKeyDown
hope that helps,
Stam
Re: Control Enter Key action
Posted: Fri Mar 18, 2022 6:54 pm
by stam
Or a simpler way to script it would be to set the autoTab property of the field - check the dictionary for
autoTab
Code: Select all
set the autoTab of <field> to {true | false}
But like i said, what you want can probably just be accomplished by ticking the
tab on return property in the field's properties inspector panel
Re: Control Enter Key action
Posted: Fri Mar 18, 2022 7:40 pm
by richmond62
You can also leverage
on enterKey:
Mind you, if one is entering text inwith a field that will just end up as a carriage return.
This is quite useful:
Code: Select all
on rawKeyDown RU
switch RU
case "65421"
focus on fld "f2"
break
case "65293"
focus on fld "f2"
break
default
pass rawKeyDown
end switch
end rawKeyDown
-