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
Control Enter Key action
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Control Enter Key action
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):
hope that helps,
Stam
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
Stam
Re: Control Enter Key action
Or a simpler way to script it would be to set the autoTab property of the field - check the dictionary for autoTab
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
Code: Select all
set the autoTab of <field> to {true | false}
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control Enter Key action
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 enterKey
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
- Attachments
-
- ENTER-TAIN-MENT.livecode.zip
- Stack.
- (1005 Bytes) Downloaded 135 times