code to set state to Disabled of individual popup menu item?

I have two popup menus. I want them to interact in such a way that when a choice is made is one menu, the middle of 3 choices is disabled in the other menu. Can someone give me the ApplescriptObjC code to disable a single menu choice in a popup menu?

(I don’t want to remove it. I want it to stay there, grayed out.)

Thanks!

Assuming you have a reference to the popup, it would probably be something like:

myPopup’s itemAtIndex_(1)'s setEnabled_(false)

I always appreciate you quick responses Shane.

That doesn’t seem to have any effect on the menu items. I did try a variant of what you gave me and used:

myPopup's itemWithTitle_("MenuItemTitleHere")'s setEnabled_(false)

and this works only when that menu item is actually selected. If not, there is no effect. Also, if I select this menu, it immediately becomes Enabled again and can be selected. I can’t find anything in my code that would do this since this is the only section that I’m dealing with this menu. Do I need to do something in IB?

Thanks.

Where did you put the code?

I have a simple method defined:

on clickmyMenu_(sender)
if () then
myPopup's itemWithTitle_("MenuItemTitleHere")'s setEnabled_(false)
else if () then

end if
end clickMyMenu_

That is the skeleton of the code and I connected that method to the PopUp menu in IB.

Maybe that would work if you put it in a mouseDown event of the popup menu?

Hi,

to change the enable property “manually” you must disable “Auto Enables Items” in Interface builder.
The best way to en-/disable menu items dynamically is to implement the method validateMenuItem: of NSObject