12 Replies Latest reply: Mar 8, 2013 7:34 PM by softwater
softwater Level 5 Level 5 (5,370 points)

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?

 

Screen Shot 2013-03-08 at 20.45.44.png


OS X Mountain Lion (10.8.2)
  • twtwtw Level 5 Level 5 (4,900 points)

    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.

  • softwater Level 5 Level 5 (5,370 points)

    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?

  • Frank Caggiano Level 7 Level 7 (25,720 points)

    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.

  • softwater Level 5 Level 5 (5,370 points)

    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:

     

     

    Screen Shot 2013-03-08 at 22.51.03.png

  • Frank Caggiano Level 7 Level 7 (25,720 points)

    The dialog Finder presets to me doesn't have a default set

    Screen Shot 2013-03-08 at 10.59.29.png

    So in your example what happens if I press return?

  • twtwtw Level 5 Level 5 (4,900 points)

    In cocoa you would make the button the panel's first responder using something like [window makeFirstResponder:button].  I'm out of practice with ASOC, though, so I'll have to think about how to implement that. 

  • softwater Level 5 Level 5 (5,370 points)

    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.

  • softwater Level 5 Level 5 (5,370 points)

    That's the 'keep both' dialogue box; it's not quite the same as the 'replace' dialog.

  • Frank Caggiano Level 7 Level 7 (25,720 points)

    I still don't understand how this works.

     

    Again the default button is returned when I hit return if I don't select an other button first. What does this other 'selected' button do? How is it selected and returned?

     

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

     

    thanks

  • Frank Caggiano Level 7 Level 7 (25,720 points)

    Ok tried a folder copy and the dialog I get is

     

    Screen Shot 2013-03-08 at 12.27.07.png

    Not even a choince to keep both. And looking at your first example what is the difference between Don't Replace and Stop?

     

    Doesn't Don't Replace just keep both (in your example) ?

     

    I got to be missing something really basic here.

  • softwater Level 5 Level 5 (5,370 points)

    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. 

  • softwater Level 5 Level 5 (5,370 points)

     

    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.