[SOLVED] 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: 50
Joined: Thu Apr 04, 2019 1:41 pm

[SOLVED] 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?
Last edited by redfield on Mon Jul 29, 2019 8:25 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3633
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 21 times

redfield
Posts: 50
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: 2124
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

redfield
Posts: 50
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 » Wed Jul 24, 2019 8:25 pm

So I have tried all suggested scripts, but nothing changes. My original script is actually sufficient and does - on Linux - what I want it to do: skip the cursor to field 2 after entering two digits in field 1. On Windows this will only work if the two digits are not entered 'too fast'. Strangely though if I enter two same digits (e. g. 11 or 22), no matter how fast, the cursor will skip to the next field, as it is supposed to. Nothing tragic but noticeable as it perfectly works on Linux, no matter how fast or slow the digits are entered in a field.

bogs
Posts: 3832
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Wed Jul 24, 2019 8:55 pm

Smells like a bug report should be filed.
Image

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2124
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] » Wed Jul 24, 2019 9:36 pm

@redfield.
My script (on keyDown) works here on Mac, Win and linux. Can only be disturbed by a "counteracting" keyUp.
Your script (on keyUp) may have problems because a "fast" keyDown comes before the pending actions from your last keyUp.
shiftLock happens

redfield
Posts: 50
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 » Thu Jul 25, 2019 1:26 pm

Hi -hh,
yes this code works fine (on Linux and Windows):

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
Only that it's not exactly what I want. After having entered two digits, the user has to hit a key one more time, before the cursor skips. But I actually want the cursor to skip directly after the second digit has been entered. Which works perfectly fine with my original script, but again on Linux only (don't know about Mac, have none).

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5116
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Thu Jul 25, 2019 4:34 pm

Try breaking it up into two handlers.

Code: Select all

-- script of fld 1
on keyDown k
  if length(me) < 2 then pass keyDown
end keyDown

on keyUp k
  if length(me) >= 2 then
    select text of fld 2
  end if 
 end keyUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

redfield
Posts: 50
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 Jul 28, 2019 7:33 pm

Have tried that too now, but unfortunately it doesn't change anything. The weird 'don't-type-too-fast' behaviour remains (on Windows). :(

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6861
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Sun Jul 28, 2019 7:55 pm

I wonder if the textChanged message may be more reliable in this context.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

redfield
Posts: 50
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 » Mon Jul 29, 2019 8:22 pm

In fact that works like a charme! The code is now:

Code: Select all

on textChanged
   if length(me) > 1 then
      select text of fld 2
   end if
end textChanged
Cursor is finally responding as it should to my racy typing skills, on both, Linux and Windows :D

Post Reply

Return to “Windows”