applescriptapplescript-objc

AppleScript: multiple buttons in "choose from list"


I have a script which makes users choose from different options in a list. I want there to be three buttons; OK, Cancel and Help (display a dialog with guidance).

However, it seems that I cannot use the "buttons" parameter within a list.

So how do I add additional buttons? (with a custom name, that displays a dialogue)

Current script:

set MyList to {"A", "B", "C"}

set Chosen to 
    (choose from list MyList with title "Connect to" 
    with prompt "What do you want to connect to?" 
    OK button name "Connect" cancel button name "Abort" ---and help
    with multiple selections allowed) as text

Solution

  • While choose from list only supports two buttons, you can use AppleScriptObjC to create very rich alerts/dialogs. I recommend starting with Shane Stanley's free Myriad Tables Lib. Here's an example:

    enter image description here

    To learn more, read Chapter 26:Richer Interfaces of Shane's excellent $15 book Everyday AppleScriptObjC, available here. You could also look at Dialog Toolkit on the same page. Because Cocoa alerts and dialogs provide an "accessory view", you can put many additional controls in there.