Monday, July 23, 2018

#1 2002-12-19 10:28:49 pm

Shai1
Member
Registered: 2002-11-20
Posts: 124

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...

Applescript:

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.

Applescript:

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

Thanks in advance,
D


Scripting...YAY!

Offline

 

#2 2002-12-20 06:34:04 am

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

Re: Menu Items

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.

Applescript:

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


To get a list of menu item values:

Applescript:

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:

Applescript:

{
   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"
}

Offline

 

#3 2002-12-20 11:56:28 am

Shai1
Member
Registered: 2002-11-20
Posts: 124

Re: Menu Items

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

Here is what I tried...

Applescript:

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

Thanks,
D


Scripting...YAY!

Offline

 

#4 2002-12-20 01:51:02 pm

T.J. Mahaffey
Administrator
From:: Arkansas, USA
Registered: 2002-11-20
Posts: 238
Website

Re: Menu Items

You'll need to physically *make them* on the fly:

Applescript:

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


T.J.
tj@tjmahaffey.com

Offline

 

#5 2002-12-23 11:56:39 am

Shai1
Member
Registered: 2002-11-20
Posts: 124

Re: Menu Items

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

Thanks,
D


Scripting...YAY!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)