Re: Accelerator keys in displayed buttons


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.


Join applescript@apple-dev.groups.io to automatically receive all group messages.