popup box not working

tell popup button "ImageColor" of window "prefs" to choose menu item BGImagePref

everything is defined correctly and i’ve checked the names of everthing at least 3 times.
BGImagePref is a string here, by the way (that may be the problem, but then how do you have it select with a string)

You’re using more of a gui scripting syntax than an actual object properties syntax. Unfortunately, the editor still recognizes the “choose menu item” text from the handler by the same name, so it doesn’t catch it as an error. Oh, well… here’s what you need…

tell popup button "ImageColor" of window "prefs"
	set current menu item to menu item BGImagePref
end tell

Good night… :o (yawn)
j

when i use your script i get an error:

NSArgumentEvaluationScriptError (3)

what does this mean?

thank you

i got it working, thanks.
(it turns out that it only takes an index number, instead of a string)

Actually, it will take a string, but it must match the AS name of your menu item exactly. My test project selected it just fine. If you are using a static menu, you must manually give every menu item in it an AS name in IB. If you’re creating the menu programatically, make sure to include a name in your property assignments when you create it…

make new menu item at end of menu items with properties {name:"Test", title:"This is a test", enabled:true}

Then you could use something like…

set BGImagePref to "Test"
tell popup button "ImageColor" of window "prefs"
   set current menu item to menu item BGImagePref
end tell

j

oh…thats why it didnt work. None of my menu items have AS Names.
thanks for helping a noob get his bearings in applescript studio, jobu!!