Page 4 of 5

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 10:17 am
by richmond62
Thanks, Bernd:

1. You ARE 'the man'.

2. I was being sleepy as I had already worked
out about traversal 2 weeks ago. :oops:

3. No need to use focus at all, now just using
textColor to know where to send a mouseUp
message.

Will post that code when back from church.

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 5:11 pm
by richmond62
What I wrote about textColor (while being possible) is not the method I used,
but my state of mind then was determined by

"Will post that code when back from church."

As went to church to bury a friend, and I was a bit . . .

The way to understand how I did things is to understand the context of my building a keyboard
to allow severely disabled people to type into a text field using ONLY these keys, or a subset of them:
-
keyBoardRestrictions.png
-
These can be easily mapped to a joystick, or for that matter a mouth-controlled device.

As you will see from the screen shot, my virtual keyboard is NOT complete, and needs further modification:
-
SShot 2023-03-12 at 18.09.55.png
-
This is the cardScript in the virtual keyboard palette:

Code: Select all

on openStack
   set the textColor of btn "b1" to blue
   put "1" into fld "kee"
   --focus on btn "b1"
end openStack

on arrowKey AK
   if AK = "right" then
      put fld "kee" into KEEE
      if exists(btn ("b" & KEEE)) then
         set the textColor of btn ("b" & KEEE) to red
         end if
         add 1 to KEEE
         put KEEE into fld "kee"
         if exists(btn ("b" & KEEE)) then
            set the textColor of btn ("b" & KEEE) to blue
            --focus on btn ("b" & KEEE)
         end if
      end if
      if AK = "left" then
         put fld "kee" into KEEE
         if exists(btn ("b" & KEEE)) then
            set the textColor of btn ("b" & KEEE) to red
         end if
         subtract 1 from KEEE
         put KEEE into fld "kee"
         if exists(btn ("b" & KEEE)) then
            set the textColor of btn ("b" & KEEE) to blue
            --focus on btn ("b" & KEEE)
         end if
      end if
   end arrowKey

on enterKey
   put fld "kee" into KEEY
   if exists(btn ("b" & KEEY)) then
      send "mouseUp" to btn ("b" & KEEY)
      end if
   end enterKey

on closeStack
   put 1 into Kred
   repeat until Kred > 35
      set the textColor of btn ("b" & Kred) to red
      add 1 to Kred
   end repeat
end closeStack

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 5:24 pm
by richmond62
Mind you, this is a load of old cobblers:
-
SShot 2023-03-12 at 18.23.13.png
-
as I was expecting the cursor to move BACK one character . . .

. . . instead of a SPACE and a 'q'. :shock:

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 5:41 pm
by richmond62
I would also like to know whether it is possible to show an insertion point in a field which has FOCUS turned OFF.

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 11:40 pm
by dunbarx
Richmond.

Assuming you mean simply that if the field currently does not have focus, then I believe LC will automatically give it focus if you want a blinking cursor.

Craig

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 11:42 pm
by dunbarx
Interestingly, if one has a card with a button and a field, with the field NOT in focus, and this in the button script:

Code: Select all

on mouseUp
   select after text of fld 1
end mouseUp
The field becomes focussed with a blinking cursor. But if the same line of code is executed from the message box, nothing happens.

Craig

Re: Dialog box selections using keyboard.

Posted: Sun Mar 12, 2023 11:52 pm
by jacque
If traversalOn is false then the field will not have a cursor, and apparently doesn't have a selection either, at least from the message box. This fails:

Code: Select all

put "abcde" into fld 1
select after char 2 of fld 1
put the selectedChunk
The response will refer to the message box. I imagine it will be the same from any handler. Is there a reason to turn off traversalOn?

Re: Dialog box selections using keyboard.

Posted: Mon Mar 13, 2023 10:05 am
by richmond62
The field, which is on a card on a different stack to the virtual keyboard, is blocked from receiving focus as it is part of what I hope will eventually be a joystick-controlled interface for LC/OXT to allow seriously disabled people to write computer programs.

Re: Dialog box selections using keyboard.

Posted: Mon Mar 13, 2023 12:09 pm
by richmond62
Here's another jolly problem:
-
Screen Shot 2023-03-13 at 1.06.41 pm.png
-

Code: Select all

on mouseUp
   put fld "nCHX" into CHX
   if exists(char (CHX + 1) in fld "ff") then
   select after char (CHX + 1) in fld "ff"
   put (CHX + 1) into fld "nCHX"
   end if
end mouseUp
Why is my right arrow key going on adding to fld "nCHX" when
there are only 11 characters in fld "ff"?

Re: Dialog box selections using keyboard.

Posted: Mon Mar 13, 2023 1:08 pm
by Cairoo
richmond62 wrote: Mon Mar 13, 2023 12:09 pm Why is my right arrow key going on adding to fld "nCHX" when
there are only 11 characters in fld "ff"?
According to the dictionary, the exists function always returns true when specifying a chunk of a container. Perhaps you should simply test if the chunk is empty.

Gerrie

Re: Dialog box selections using keyboard.

Posted: Mon Mar 13, 2023 1:26 pm
by bn
Here is my take on button Bleft:

Code: Select all

on mouseUp
   put fld "nCHX" into CHX
   put the number of chars of field "ff" into tNumChars
   if CHX = 0 then
      beep
   end if
   if CHX > 0 and CHX <= tNumChars then
      select after char (CHX - 1) in fld "ff"
      put min(max(tNumChars,0),CHX-1) into field "nCHX"
   end if
end mouseUp
And here for button Bright

Code: Select all

on mouseUp
   put fld "nCHX" into CHX
   put the number of chars of field "ff" into tNumChars
   if CHX = tNumChars then
      beep
   end if
   if CHX >= 0 and CHX <= tNumChars then
      select after char (CHX + 1) in fld "ff"
      put min(max(tNumChars,0),CHX+1) into field "nCHX"
   end if
end mouseUp
Your use of "exist" in this context is new to me

Kind regards
Bernd

Re: Dialog box selections using keyboard.

Posted: Tue Mar 14, 2023 12:40 pm
by richmond62
Thank you, Bernd: I was obviously being too clever with exists. 8)

Re: Dialog box selections using keyboard.

Posted: Tue Mar 14, 2023 2:11 pm
by richmond62
Screen Shot 2023-03-14 at 3.10.25 pm.png
-

Re: Dialog box selections using keyboard.

Posted: Fri Apr 14, 2023 12:26 pm
by stam
domzduzt wrote: Fri Apr 14, 2023 11:19 am I downloaded the revised stack. I can't figure how I could use this - no access to the coding for the selection buttons...
The code is in the button and card script - but. not sure what you actually mean.

On a related note, the 'forward delete' button does not work as one would imagine - it just goes to the end of line.

I'm not are what the use-case for this 'functionality' would be other than idle curiosity (I mean most would probably just use the actual arrow, delete and forward-delete keyboard keys) - perhaps if you let us know what it is you're trying to do?

S

Re: Dialog box selections using keyboard.

Posted: Fri Apr 14, 2023 12:58 pm
by Klaus
Hi Stam,

I keep an eye on this possible spammer! ;-)


Best

Klaus