I am writing a program where when certain windows or sheets are on the screen I need to enable and disable menu items. It looks like I should put a - (BOOL)validateMenuItem

id <NSMenuItem> )menuItem method into the class definitions of those windows in which I want to control the behavior of the menus. There's only one problem. You see, in my program you can open and save stuff but there is only one document open at a time. This is on purpose. What I am worried about is that if a user switches from the main window, which might have a sheet open that I have told to disable a few menus, to another window, then those menus will become enabled again. The program will either crash or act strangely if the user chooses one of those menu items when it is supposed to be disabled.
In order to cope with that I tried forgetting about NSMenuValidation at all and explicitly enabling my menus and disabling them when the time came. I turned autoenabling off using the - (void)setAutoenablesItems

BOOL)flag in NSMenu, however, I found that - (void)setEnabled

BOOL)flag in NSMenuItem didn't do anything at all. Yes, after I used it - (BOOL)isEnabled in NSMenuItem would return NO, but the menu would never change. I tried using - (void)itemChanged

id <NSMenuItem> )anObject in NSMEnu but that didn't work either.
So I tried leaving autoenabling on and simply setting the targets of the menu items I wanted to disable to NULL. This worked most of the time but some of the time it didn't. I think that it has to do with when NSMenuValidation checks to see if the menu items were changed or not.
So, what is the best way for me to enable or disable menu items in my program?
- update: Fixed the smilies.
[This message has been edited by Dalgo (edited 01-24-2001).]