Popup Button and Choose Menu Item

I have a “Choose Menu Item” handler selected for my popup button, and the menu item. Yet no matter what I do, I get an “NSReceiverEvaluationScriptError: 3 (1)”. This seems to be because theres an action attached to the menu item, yet to reciever for the action. The problem is, I have the item named (in IB), and use

on choose menu item theobject
if the name of theobject = "menuitem" then
display dialog hello"
end if
end choose menu item

But it just doesn’t work.

It’s driving me mad, as to why this doesn’t work. I’ve used Popup buttons many times before to get “preferences”, but never to get an action. (someone choosing it) Can anyone tell me what I’m doing wrong?

Nevermind, figured it out goofing off using title. You enable on choose menu item for the actual popup button, then link it to the script, link each item to the script and then use “if the title of theObject = “title of item” then”.

Wtf is choose menu item doing there if it’s practically useless?

Try:

on choose menu item theObject
	if name of current menu item of theObject is "menuitem" then
		display dialog "hello"
	end
end choose menu item

Since the popup button also has a name. :wink:

tried it. didn’t work.

not directly, but:

set theobject2 to the name of the current menu item of theobject
if theobject2 = "stuff" then
end if