Page 1 of 5

Dialog box selections using keyboard.

Posted: Mon Feb 13, 2023 1:32 pm
by CAsba
Hi,
Is there a (reasonably easy) way to let the user use the keyboard, arrows or tab, to move to another option in the dialog box?

Re: Dialog box selections using keyboard.

Posted: Mon Feb 13, 2023 2:00 pm
by richmond62
Can't see you managing that with this:
-
Screen Shot 2023-02-13 at 2.59.22 pm.png

Re: Dialog box selections using keyboard.

Posted: Mon Feb 13, 2023 2:24 pm
by CAsba
Hi,
Thanks for that, you probably saved me a lot of time trying; good to get your experienced opinion.

Re: Dialog box selections using keyboard.

Posted: Mon Feb 13, 2023 3:13 pm
by dunbarx
CAsba

Dialog boxes like "Ask" and "Answer" block all but a very few actions, particular to each. Clicking one of the presented buttons (or using "Enter" or "Return" to select the default), along with the ability to enter text in an "ask" dialog is all she wrote.

Craig

Re: Dialog box selections using keyboard.

Posted: Mon Feb 13, 2023 3:24 pm
by richmond62
mouse.jpeg
-
It's a mouse-driven age. 8)

Re: Dialog box selections using keyboard.

Posted: Tue Feb 14, 2023 9:49 am
by richmond62
Let's have slightly dubious fun setting up a substack as a dialog thingy:
-
Screen Shot 2023-02-14 at 10.47.48 am.png
-
set the traversalOn of ALL the buttons to true.

Re: Dialog box selections using keyboard.

Posted: Tue Feb 14, 2023 10:03 am
by richmond62
Here's a fake dialog palette:
-
Screen Shot 2023-02-14 at 11.00.42 am.png
-
You can use the RIGHT ARROW key to change the selected button.

You can use the ENTER (not the 'Return' key) to activate the selected button.

Code: Select all

on openStack
   focus on btn "B1"
   set the textColor of btn "B1" to red
end openStack

on enterKey
   send "mouseUp" to the focusedObject
end enterKey

on arrowKey AK
   if AK = "right" then
      if the textColor of btn "B3" is red then
         focus on btn "B1"
          set the textColor of btn "B3" to black
          set the textColor of btn "B1" to red
          end if
      if the textColor of btn "B2" is red then
         focus on btn "B3"
          set the textColor of btn "B2" to black
          set the textColor of btn "B3" to red
          end if
      if the textColor of btn "B1" is red then
         focus on btn "B2"
          set the textColor of btn "B1" to black
          set the textColor of btn "B2" to red
       end if
       end if
    end arrowKey
    
    on closeStack
       set the textColor of btn "B1" to black
       set the textColor of btn "B2" to black
       set the textColor of btn "B3" to black
    end closeStack
The reason I change the button text to red is because LiveCode gives NO visual cue (bad) when a button
receives focus.

Re: Dialog box selections using keyboard.

Posted: Tue Feb 14, 2023 6:34 pm
by jacque
CAsba wrote:
Mon Feb 13, 2023 1:32 pm
Hi,
Is there a (reasonably easy) way to let the user use the keyboard, arrows or tab, to move to another option in the dialog box?
It's a system setting. As long as all controls have traversalOn set to true, it's automatic on Windows (and those users expect it.) On Mac the user can turn on the setting in system prefs. If they haven't done that it's probably better to leave things alone since they will be used to clicking dialog options.

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 12:08 pm
by richmond62
I did it my way.

AND it works.

SO, you have to decide whether to stick to some vague
orthopraxis, or break out and get the functionality you require.

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 5:11 pm
by CAsba
Thanks for that..
I did it this way...

Code: Select all

 answer question "You have entered the business name as:- " & CRLF & CRLF &\
               field "compnamex" of card "template1" & CRLF & CRLF &\ 
               "Is this correct?"  with "YES" or "NO"
         set the traversalon of btn "YES" to true 
         set the traversalon of btn "NO" to true 
         put it into field "fieldcr" of card "template1"
and it allows the user to tab to change selection.
Now I've got to dream up a way to inform the user of this facility...

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 5:23 pm
by Klaus
You can save some typing! :-)
Internally LC ALWAYS uses CR as a line delimiter!

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 5:37 pm
by dunbarx
What Richmond did is fine because he rolled his own dialog box. That is just another LC gadget.

But for a minute I thought that CAsba had made that handler

Code: Select all

 answer question "You have entered the business name as:- " & CRLF & CRLF &\
               field "compnamex" of card "template1" & CRLF & CRLF &\ 
               "Is this correct?"  with "YES" or "NO"
         set the traversalon of btn "YES" to true 
         set the traversalon of btn "NO" to true 
         put it into field "fieldcr" of card "template1"
work on a "standard" answer dialog, that he was able to access the "Yes" and "No" buttons on the dialog itself. No way, and I do not want anyone else to think such a thing is possible.

Craig

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 6:08 pm
by Klaus
Yes Craig and then these two lines are completely meaningless:

Code: Select all

set the traversalon of btn "YES" to true 
set the traversalon of btn "NO" to true 
Even if put BEFORE the "answer..." dialog!

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 7:22 pm
by richmond62
You either do it 'my way', or you do it 'his way' ( Atkinson, MetaCard, Miller), but do NOT mix-and-match, as it will only end in tears before bedtime.

Re: Dialog box selections using keyboard.

Posted: Wed Feb 15, 2023 8:07 pm
by dunbarx
Klaus.

That is actually what threw me. The original intent was to be able to "work" the buttons that are presented in a standard dialog box. I asserted that was not possible, that they were unavailable for access apart from a limited number of allowed user actions, like clicking on them. But not to select one of their presented buttons by, say, arrow key or tab key.

It is simple and satisfying to roll your own; have it your way. I do it now and then, and though always happy with the result, and no offense to anyone, I am rarely particularly proud of my efforts.

All I wanted to say was that modal dialog boxes are not accessible at all beyond the few actions they permit.

Craig