Topics

Accelerator keys in displayed buttons

Jean-Christophe Helary <jean.christophe.helary@...>
 

I'm wondering if it's possible to set accelerator keys to access displayed buttons from the keyboard, instead of having to use the mouse.

For ex: buttons {"Action", "Reaction"} where hitting "A" on the keyboard would trigger "Action" and "R" "Reaction...

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Robert Poland
 

Since accelerator keys “ are a PC function, I’m confused by your request. Are you using a Mac or a PC. Which model and OS.

If a Mac, look into Keyboard Maestro. https://www.keyboardmaestro.com/main/

On Dec 24, 2017, at 12:50 AM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'm wondering if it's possible to set accelerator keys to access displayed buttons from the keyboard, instead of having to use the mouse.

For ex: buttons {"Action", "Reaction"} where hitting "A" on the keyboard would trigger "Action" and "R" "Reaction...

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Robert Poland
Fort Collins, CO

Jean-Christophe Helary <jean.christophe.helary@...>
 

Sorry for the inappropriate term use.

I mean when you have a normal dialog on Mac and you can access the button with a keyboard combination without having to click on the buttons.

Jean-Christophe

Dec 24, 2017 22:58、Robert Poland <rpoland@...>のメール:

Since accelerator keys “ are a PC function, I’m confused by your request. Are you using a Mac or a PC. Which model and OS.

If a Mac, look into Keyboard Maestro. https://www.keyboardmaestro.com/main/

On Dec 24, 2017, at 12:50 AM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'm wondering if it's possible to set accelerator keys to access displayed buttons from the keyboard, instead of having to use the mouse.

For ex: buttons {"Action", "Reaction"} where hitting "A" on the keyboard would trigger "Action" and "R" "Reaction...

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com
Robert Poland
Fort Collins, CO
Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Jean-Christophe Helary <jean.christophe.helary@...>
 

Dec 25, 2017 2:40、Robert Poland <rpoland@...>のメール:

It appears that NOW you can use the Tab key to select which button you want then hit return to activate it.
Not on dialogs created with "display dialog". Or not on 10.13. Anyway, my "display dialog" buttons are stuck in the state I define and I can't move around them with the keyboard. Only when I define a cancel button is "esc" registered also to that button.

Jean-Christophe


On Dec 24, 2017, at 7:57 AM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Sorry for the inappropriate term use.

I mean when you have a normal dialog on Mac and you can access the button with a keyboard combination without having to click on the buttons.

Jean-Christophe

Dec 24, 2017 22:58、Robert Poland <rpoland@...>のメール:

Since accelerator keys “ are a PC function, I’m confused by your request. Are you using a Mac or a PC. Which model and OS.

If a Mac, look into Keyboard Maestro. https://www.keyboardmaestro.com/main/

On Dec 24, 2017, at 12:50 AM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'm wondering if it's possible to set accelerator keys to access displayed buttons from the keyboard, instead of having to use the mouse.

For ex: buttons {"Action", "Reaction"} where hitting "A" on the keyboard would trigger "Action" and "R" "Reaction...

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Robert Poland
 

This script works as I said with OS10.13.2.

display dialog "See the pretty buttons!" buttons {"Cancel", "OK", "Some other button"} cancel button "Cancel" default button "OK"

On Dec 24, 2017, at 2:57 PM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Dec 25, 2017 2:40、Robert Poland <rpoland@...>のメール:

It appears that NOW you can use the Tab key to select which button you want then hit return to activate it.

Not on dialogs created with "display dialog". Or not on 10.13. Anyway, my "display dialog" buttons are stuck in the state I define and I can't move around them with the keyboard. Only when I define a cancel button is "esc" registered also to that button.

Jean-Christophe

On Dec 24, 2017, at 7:57 AM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Sorry for the inappropriate term use.

I mean when you have a normal dialog on Mac and you can access the button with a keyboard combination without having to click on the buttons.

Jean-Christophe

Dec 24, 2017 22:58、Robert Poland <rpoland@...>のメール:

Since accelerator keys “ are a PC function, I’m confused by your request. Are you using a Mac or a PC. Which model and OS.

If a Mac, look into Keyboard Maestro. https://www.keyboardmaestro.com/main/

On Dec 24, 2017, at 12:50 AM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'm wondering if it's possible to set accelerator keys to access displayed buttons from the keyboard, instead of having to use the mouse.

For ex: buttons {"Action", "Reaction"} where hitting "A" on the keyboard would trigger "Action" and "R" "Reaction...

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Robert Poland
Fort Collins, CO

Jean-Christophe Helary <jean.christophe.helary@...>
 

Not in 10.13 on my machine. Tab won't change the focus.

Jean-Christophe

Dec 25, 2017 8:39、Robert Poland <rpoland@...>のメール:

This script works as I said with OS10.13.2.

display dialog "See the pretty buttons!" buttons {"Cancel", "OK", "Some other button"} cancel button "Cancel" default button "OK"

On Dec 24, 2017, at 2:57 PM, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Dec 25, 2017 2:40、Robert Poland <rpoland@...>のメール:

It appears that NOW you can use the Tab key to select which button you want then hit return to activate it.
Not on dialogs created with "display dialog". Or not on 10.13. Anyway, my "display dialog" buttons are stuck in the state I define and I can't move around them with the keyboard. Only when I define a cancel button is "esc" registered also to that button.

Jean-Christophe

Shane Stanley
 

On 25 Dec 2017, at 11:20 am, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Tab won't change the focus.
It will if you go to Preferences -> Keyboard -> Shortcuts and change Full Keyboard Access to All controls. But if you do so, you'll probably also find the side-effects more annoying than it's worth.

--
Shane Stanley <sstanley@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

Jean-Christophe Helary <jean.christophe.helary@...>
 

On Dec 25, 2017, at 10:13, Shane Stanley <sstanley@...> wrote:

On 25 Dec 2017, at 11:20 am, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Tab won't change the focus.
It will if you go to Preferences -> Keyboard -> Shortcuts and change Full Keyboard Access to All controls. But if you do so, you'll probably also find the side-effects more annoying than it's worth.
Yes, but that's not what there is in normal Mac apps, or am I wrong?
I'd like to have something that acts as normal Mac dialogs. Is that possible?



Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Shane Stanley
 

On 25 Dec 2017, at 12:22 pm, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'd like to have something that acts as normal Mac dialogs.
"Normal" Mac dialogs don't show keyboard equivalents.

--
Shane Stanley <sstanley@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

Jean-Christophe Helary <jean.christophe.helary@...>
 

On Dec 25, 2017, at 10:56, Shane Stanley <sstanley@...> wrote:

On 25 Dec 2017, at 12:22 pm, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'd like to have something that acts as normal Mac dialogs.
"Normal" Mac dialogs don't show keyboard equivalents.
Maybe not all, but some buttons can be accessed by hitting Cmd+the first letter, or something like this. It used to be that a TextEdit dialog reacted to Cmd+D for Delete, but now it is "Change location to Desktop", etc.

Anyway, normal or not, that's the kind of thing I'd like to implement. Is that possible?


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Shane Stanley
 

On 25 Dec 2017, at 1:03 pm, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Maybe not all, but some buttons can be accessed by hitting Cmd+the first letter, or something like this. It used to be that a TextEdit dialog reacted to Cmd+D for Delete, but now it is "Change location to Desktop", etc.

I suspect you're thinking of "Don't Save".  Alerts are hard-wired by default to map escape/command-. to Cancel, return to OK, and command-D to Don't Save:

display alert "Test" buttons {"Cancel", "Don't Save", "OK"}

Anyway, normal or not, that's the kind of thing I'd like to implement. Is that possible?

Not in standard AppleScript, no -- you can map the buttons that respond to escape/command-. and return, but that's all.


Jean-Christophe Helary <jean.christophe.helary@...>
 

On Dec 25, 2017, at 11:11, Shane Stanley <sstanley@...> wrote:

Maybe not all, but some buttons can be accessed by hitting Cmd+the first letter, or something like this. It used to be that a TextEdit dialog reacted to Cmd+D for Delete, but now it is "Change location to Desktop", etc.
I suspect you're thinking of "Don't Save". Alerts are hard-wired by default to map escape/command-. to Cancel, return to OK, and command-D to Don't Save:

display alert "Test" buttons {"Cancel", "Don't Save", "OK"}
Ok. I'm pretty sure I've seen them in other places too, but I'm fine with your answer.

Anyway, normal or not, that's the kind of thing I'd like to implement. Is that possible?
Not in standard AppleScript, no -- you can map the buttons that respond to escape/command-. and return, but that's all.
Return being the default button, right ?


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Shane Stanley
 

On 25 Dec 2017, at 1:34 pm, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'm pretty sure I've seen them in other places too

Those I mentioned are just the built-in defaults. Custom shortcuts can be applied to any buttons -- just not using "display dialog" or "display alert".

A simple example is my Dialog Toolkit Plus library. Here's the Simple sample.scpt file that ships with it:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Dialog Toolkit Plus" version "1.0"

set accViewWidth to 650
set {theButtons, minWidth} to create buttons {"Cancel", "Five", "Four", "Three", "Two", "One", "OK"} button keys {"", "5", "4", "3", "2", "1", ""} cancel button 1 default button 7
if minWidth > accViewWidth then set accViewWidth to minWidth -- make sure buttons fit
set {theField, theTop} to create field "" placeholder text "Enter your text here" bottom 0 field width accViewWidth extra height 60 with accepts linebreak and tab
set {boldLabel, theTop} to create label "How many buttons would you like? There's no real limit except for practical and aesthetic considerations." & return & "Of course, I hope you'll never really think about using something as ugly as this!" & return & return & "Choose your heart out!" & return & return & "Also, try the command-1 thru command-5 button shortcuts." bottom theTop + 20 max width accViewWidth control size regular size
set {buttonName, controlsResults} to display enhanced window "Many Buttons" acc view width accViewWidth acc view height theTop acc view controls {theField, boldLabel} button list theButtons active field theField initial position {0, 0} with align cancel button


Return being the default button, right ?

Yes.


Jean-Christophe Helary <jean.christophe.helary@...>
 

On Dec 25, 2017, at 11:59, Shane Stanley <sstanley@...> wrote:

On 25 Dec 2017, at 1:34 pm, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I'm pretty sure I've seen them in other places too
Those I mentioned are just the built-in defaults. Custom shortcuts can be applied to any buttons -- just not using "display dialog" or "display alert".
Ok.

A simple example is my Dialog Toolkit Plus library. Here's the Simple sample.scpt file that ships with it:
Thank you!


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com

Robert Poland
 

Shane,

Could you elaborate on the side-effects you are referred to?

I haven’t noticed anything.

On Dec 24, 2017, at 6:13 PM, Shane Stanley <sstanley@...> wrote:

On 25 Dec 2017, at 11:20 am, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Tab won't change the focus.

It will if you go to Preferences -> Keyboard -> Shortcuts and change Full Keyboard Access to All controls. But if you do so, you'll probably also find the side-effects more annoying than it's worth.

--
Shane Stanley <sstanley@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

Robert Poland
iMac, Late 2013, 14,2
  3.2 GHz Intel Core I5, 27” 
  16 GB Ram, 1TB Fusion HD
  OS X 10.13.2 (High Sierra)

Shane Stanley
 

On 26 Dec 2017, at 2:33 am, Robert Poland <rpoland@...> wrote:

Could you elaborate on the side-effects you are referred to?
The main thing it does is destroys the tabbing order. By default, tabbing takes you through the fields of a dialog in a left-to-right/top-to-bottom order, but in more complex dialogs developers often override this to provide a more logical flow. As soon as you turn on Full Keyboard Access, that goes out the window. And for what? In many cases tabbing highlights a control, but you still have to click on it to make it do anything.

It should be useful, but it's poorly implemented.

--
Shane Stanley <sstanley@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

Peter Gort
 

Actually, once a control has focus, tapping the space bar will action that control, and once you are used to this, it means you don’t have to move your hand from the keyboard to the mouse nearly as often.  I make use of this when scripting the interface, often when sending a click event to a button whose associated action creates a new window, interface scripting pauses for 5 seconds after the window is drawn, then resumes the script.  However typing a space actions the control and the 5 second pause does not happen.  Weird but true.

Peter Gort

On 26 Dec 2017, at 9:20 am, Shane Stanley <sstanley@...> wrote:

In many cases tabbing highlights a control, but you still have to click on it to make it do anything.

Jean-Christophe Helary <jean.christophe.helary@...>
 

On Dec 25, 2017, at 11:11, Shane Stanley <sstanley@...> wrote:

On 25 Dec 2017, at 1:03 pm, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Maybe not all, but some buttons can be accessed by hitting Cmd+the first letter, or something like this. It used to be that a TextEdit dialog reacted to Cmd+D for Delete, but now it is "Change location to Desktop", etc.
I suspect you're thinking of "Don't Save". Alerts are hard-wired by default to map escape/command-. to Cancel, return to OK, and command-D to Don't Save:

display alert "Test" buttons {"Cancel", "Don't Save", "OK"}
I found a new one: when adding a file extension to a file, Finder asks "Add ..." and "Don't add ..." and Cmd+A triggers "Add ..."



Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com