How do I enable a menu item ?
12/07/03 22:38
I don't understant the Cocoa way to enable/disable menu items…
Menu items are enabled by several conditions:
first, either the menu item must have an action selector defined: if there is no selector associated to the menu item (either programmatically either by defining it in IB), the menu will always be disabled;
then Cocoa looks if the current responder chain contains the target of the menu action and if the responder implements a - (BOOL)validateUserInterfaceItem:(id)anItem , it calls it and then enable/disable the menu item according to the answer.
If you don't implement validateUserInterfaceItem, the menu will be enabled if the target of its associated action selector becomes active.
If you do implement validateUserInterfaceItem in the target, it will be called to decide to validate or not the menu item.
first, either the menu item must have an action selector defined: if there is no selector associated to the menu item (either programmatically either by defining it in IB), the menu will always be disabled;
then Cocoa looks if the current responder chain contains the target of the menu action and if the responder implements a - (BOOL)validateUserInterfaceItem:(id)anItem , it calls it and then enable/disable the menu item according to the answer.
If you don't implement validateUserInterfaceItem, the menu will be enabled if the target of its associated action selector becomes active.
If you do implement validateUserInterfaceItem in the target, it will be called to decide to validate or not the menu item.