Menu Items

I’ve been trying to work with a popup menu and am having problems getting the list or setting the list. Here is the code I’ve been trying…

set theList to menu items of popup button "Test" of (window of theObject)

I keep getting an empty list. I’ve been using the following code to try and set the menu items…it doesn’t return an error, but when I click the popup after the script has run I can see some errors occur in PB in the background.

set menu items of popup button "Test" of (window of theObject) to {"TEST","TEST2"}

Thanks in advance,
D

To get a list of menu item values:

title of menu items of menu of popup button "menusen" of window "amundssen"

If you don’t use “title of”, you get a list of references, such as:

{
	menu item id 25 of item id 4 of application "La Faraona", 
	menu item id 5 of item id 4 of application "La Faraona", 
	menu item id 6 of item id 4 of application "La Faraona", 
	menu item id 7 of item id 4 of application "La Faraona"
}

So that worked for getting the values of a popup…but I’m still having trouble setting the values.

Here is what I tried…

set title of menu items of menu of popup button "TitleList" of (window of theObject) to myList

Thanks,
D

You’ll need to physically make them on the fly:

repeat with  i in theList
		make new menu item at the end of menu items of menu of popup button "my_popup_button" of window "my_window" with properties {title:i, enabled:true}
	end repeat

Unlike FaceSpan, you can’t “set” menu items of a popup button to a list. FaceSpan actually let you set the contents of a popup to a list. That was beautiful. But you’ll have to be more implicit with AStudio. It’s wordy as heck, but it works like a champ. :wink:

Well that kinda stinks, but if it works I guess that’s what is important.

Thanks,
D