Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

applescript: dialog button (spacebar activates)

Friends


I know how to specify the default button (return/enter activates) for a display dialog box, but I can't find anywhere in my documentation sources that gives a way to specify the button that is activated by spacebar (see screenshot). Possibly because I don't even know what to call it — 'secondary default button', perhaps?


Does anyone know what the applescript command is for this setting?


User uploaded file

OS X Mountain Lion (10.8.2)

Posted on Mar 8, 2013 5:52 AM

Reply
Question marked as Best reply

Posted on Mar 8, 2013 6:53 AM

That's the focused item, and there's no way to set it from applescript that I know of. The focused item is the one that first catches keyboard events. The return key is automatically routed to the default button, but the space key acts like a click on the focused item (unless it's an editable text field), and the tab key moves the focus to the next item.

12 replies
Question marked as Best reply

Mar 8, 2013 6:53 AM in response to softwater

That's the focused item, and there's no way to set it from applescript that I know of. The focused item is the one that first catches keyboard events. The return key is automatically routed to the default button, but the space key acts like a click on the focused item (unless it's an editable text field), and the tab key moves the focus to the next item.

Mar 8, 2013 6:53 AM in response to twtwtw

twtwtw wrote:


That's the focused item, and there's no way to set it from applescript that I know of.


Yeah, I was afraid of that. I've seen some dialgoues that have both the default button and the 'focus' button highlighted, but I guess that's done using a cocoa class of some sort.


That leads to the next question. Any cocoa-applescript gurus out there know how it's done?

Mar 8, 2013 7:37 AM in response to softwater

This is not an idiom I believe I have ever seen. In what apps did you see this?


The default button by definition has the focus. The default button has to have the focus as that is what is returned if noting is specifically chosen.


Is what you are looking for is that one button is run if the return key is pressed but if the space bar is pressed another button is selected? Spacebar by itself doesn't not normally dismiss a dialog.

Mar 8, 2013 7:55 AM in response to Frank Caggiano

Frank Caggiano wrote:


This is not an idiom I believe I have ever seen. In what apps did you see this?



Thanks for your response, Frank.


The screenshot I provided above is an OS X system response (Finder). I find it hard to believe you've never seen the outlined focus button!


Here's an example of both the return default and the spacebar 'focus' button both being highlighted. This is the behaviour I want to implement in my app:



User uploaded file

Mar 8, 2013 8:12 AM in response to twtwtw

Thanks, twtwtw.


My understanding (rusty and basic) of the firstResponder method was that it sets the same as the default button command.


Anyway, it seems we're all a bit in the dark here. Looks like this developer doc is the first port of call. If I get to the bottom of it (I have to admit, its only a 'desirable'' rather than a 'critical' addition to my app), I'll post back.

Mar 8, 2013 7:28 PM in response to Frank Caggiano

I'm not sure why yours is different, Frank. Are you using 10.8.2? You may need to have 'All Controls' selected in System Prefs > Keyboard | Full Keyboard Access, perhaps?


I assume the difference between 'stop' and 'don't replace' is the latter will continue onto the next file (suppose you'd made multiple selections), whereas the former will halt the entire operation.


As for the highlighted outline ('focus'?) button, this is sometimes highlighted automatically along with the default button. Hitting return returns the default button, hitting spacebar returns the 'focus' button, and hitting esc returnts the cancel button.


Other times it's not highlighted, but will become so if you use the tab key to move between buttons. Again, you use the spacebar to choose it, not the return key.

Mar 8, 2013 7:34 PM in response to Frank Caggiano


I'm really interested. I just cannot see what the use of this is if it is even doable.



Ah sure. The point is that it means you have two buttons in a dialog that can be chosen from the keyboard (the default key with 'return', and the highlighted key with spacebar) instead of only the one default button.


Some of us are keyboard junkies 😉 and hate reaching for those superfluous other devices. Also being able to move the 'highlighted' button with the tab key and choose it with the spacebar is really useful.

applescript: dialog button (spacebar activates)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.