Make the cursor move to next field ('select before text' not always working)

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
redfield
Posts: 37
Joined: Thu Apr 04, 2019 1:41 pm

Make the cursor move to next field ('select before text' not always working)

Post by redfield » Wed Jun 26, 2019 8:21 pm

Hi,
I have two fields and after a two-digit input in Field1 the cursor should move to Field2, without having to press tab or so. This is the script:

Code: Select all

on keyUp
   if length(me) = 2 then
      select before text of fld "Field2"
   end if
end keyUp
This works fine in the Linux standalone. But in the Windows standalone the cursor move only happens, if the two digits in Field1 are entered quite slowly. Meaning it depends on the input speed, if the cursor moves to Field2 or not. This seems a little strange. Is there a better way to script the desired cursor move?

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

Re: Make the cursor move to next field ('select before text' not always working)

Post by richmond62 » Wed Jun 26, 2019 10:15 pm

In terms of stacks (rather than standalones I made this:
-
Fshift.png
-
The code in fld "Field1" goes like this:

Code: Select all

on keyUp KP
   if length(me) > 1 then
      put empty into fld "Field2"
      select before fld "Field2"
   end if
end keyUp
I feel "a bit funny" about using keyUp without a variable after it.

I also feel that select before fld "Field2" is preferable to select before text of fld "Field2".

Whether this will make any difference in terms of functionality when
standalones are built has yet to be seen.
Attachments
Field Shift.livecode.zip
Here's the stack.
(1.01 KiB) Downloaded 8 times

redfield
Posts: 37
Joined: Thu Apr 04, 2019 1:41 pm

Re: Make the cursor move to next field ('select before text' not always working)

Post by redfield » Sun Jun 30, 2019 9:04 pm

Many thanks for your suggestions. I tried them but unfortunately the problem remains: the cursor won't skip to the next field if the text in the first field is input too quickly - this though goes for the Windows standalone only. :?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2028
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Make the cursor move to next field ('select before text' not always working)

Post by [-hh] » Mon Jul 01, 2019 9:08 am

The following should work (close to that what you want).
It inputs at most two chars into fld 1, the keystroke for the third char selects the text of fld 2.
Contrary to your approach you can also edit fld 1.

Code: Select all

-- script of fld 1
on keyDown k
  if length(me) > 1 then
    select text of fld 2
    -- put k into fld 2 -- optional
  else pass keyDown
end keyDown
shiftLock happens

Post Reply

Return to “Windows”