AppleScript display dialog and choose from list in same window?

Is this possible? I want applescript to provide a choose from list window with a couple options or whatever, but when you click on one of the options, more information about your selection is shown to the right of the list, So select Sunday from the list and on the right it says "The first day of the week". Select Monday and it will change. Keep in mind that I want all of this to happen before anyone presses the "Choose" button for the list after selecting something. Is this possible? Or is there some other way to do this through applescript like shell script or something? Sorry not familiar with any of it just trying to learn through trial and error. Thanks in advance!

MacBook Pro with Retina display, OS X Mavericks (10.9.1), Base Model, 2.3, 8gb RAM

Posted on Jul 26, 2014 7:58 PM

Reply
14 replies

Jul 26, 2014 8:28 PM in response to alexk403

Regular AppleScript does not have the ability to do anything like this, but a Cocoa-AppleScript can, through either Xcode or a Cocoa-Applet from the AppleScript Editor. The user interface is a bit easier to build in Xcode, but you need to be familiar with Xcode, and using the AppleScript Editor will require building the user interface manually. I am going to guess that your user interface will consist of a popup button, a text field, and a push button, so either way you would also need to know a little about the related Cocoa classes.




MacBook Pro / OS X Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW

Jul 27, 2014 5:59 PM in response to alexk403

Regular AppleScript has an alert dialog and a choose from list dialog, but they aren't designed to be used together - anything beyond these basic dialogs you would have to build yourself. If you could describe your exact requirements, perhaps something could be built using a Cocoa-AppleScript Applet from the AppleScript Editor.


Another option would be to use something like Pashua, although you would need to build your interface there as well.




MacBook Pro / OS X Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW

Jul 27, 2014 6:09 PM in response to red_menace

Sure. My exact requirements would be a window titled "TV Show Maker 3.0" and within the window has the instructions "Please select the correct TV Show, then press OK." At the bottom would be cancel button which would cancel the script and close the window, and the OK button that would close the window. A list of names of tv shows is displayed in a column so that all of them are visible (or at least several with a scroll, exactly how the choose from list applescript GUI looks) with a default selection on the first item of the list.


Now, the location of these names can depend on whatever would be the best avenue. Let me explain. I have a list of lists (called seriesResults), each list is a series (tv series) and within each list is several items, say item 1 is series id, item 2 is series name, and item 3 is original air date and item 4 is overview. So the choose from list has the series names from each series in the list (item 2). Now multiple selection is not allowed, so depending on which series name is selected, the corresponding air date and overview is shown in a text box to the right of the choose from list. So select the first series name in the list, and item 3 and item 4 of item 1 of seriesResults is displayed in the corresponding text boxes to the right. The air date text box would have a label like "Original Air Date:" but the overview one wouldn't need a label. Then, when a selection is made and the OK button is pressed, the actual thing I need from all of this is the series id (item 1 of each series). So if that could somehow be extracted. Or I could just have the seriesName and then use a repeat function to cycle through all of the lists, find the series match, then get the corresponding series id.


That is pretty much exactly what I need to do. Let me know if you don't understand anything. Thanks a lot.

Jul 27, 2014 6:53 PM in response to red_menace

the name is a string, everything is in string form, and it is the name of a TV series. The list of lists is just set to a variable seriesResults. A table view might work. The only problem is that the name and air date are going to be relatively short, while the overview is more like a paragraph and I would like the whole overview to be visible. Also, I don't necessarily need the air date and overview of EVERY item shown all the time, only the item that is selected.

Jul 27, 2014 7:48 PM in response to alexk403

Something like this?

User uploaded file

The table view would just be a single column that allows a single selection, the overview (which is loaded when an item is selected in the table view) would be a scrolling text view so that it can hold however much text is needed, and the Select button would return the ID of the currently selected item.


It will take a bit of my spare time to make a controller script and reconstruct in the Cocoa-AppleScript template, but it looks like this could be useful as a general-purpose dialog.




MacBook Pro / OS X Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW

Jul 27, 2014 7:51 PM in response to red_menace

WOW! This is perfect. Absolutely if this is something you could do I could never repay you. And take as much time as you need it is more of a luxury item for my program than a necessity. And just curious would I be able to edit the GUI to rename things and move around boxes/labels as I please so I can use it on other programs as well? Thanks a lot.

Aug 3, 2014 3:24 PM in response to alexk403

OK, I now have a working template/application that puts up a modal dialog window - it can be downloaded here. The template includes an example application and I have broken out the various frames so that sizes and locations can be changed reasonably easily. If you would post or email back with some test data and exactly how you are wanting to use the dialog in your application, I can do some additional fine tuning.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript display dialog and choose from list in same window?

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