Control Enter Key action

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trags3
Posts: 418
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Control Enter Key action

Post by trags3 » Fri Mar 18, 2022 6:31 pm

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

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

Re: Control Enter Key action

Post by stam » Fri Mar 18, 2022 6:39 pm

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

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

Re: Control Enter Key action

Post by stam » Fri Mar 18, 2022 6:54 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9361
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Control Enter Key action

Post by richmond62 » Fri Mar 18, 2022 7:40 pm

You can also leverage on enterKey:

Code: Select all

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
-
SShot 2022-03-18 at 20.38.25.png
Attachments
ENTER-TAIN-MENT.livecode.zip
Stack.
(1005 Bytes) Downloaded 114 times

Post Reply

Return to “Windows”