MOExtendedMenuItem is a subclass of NSMenuItem that adds support for a "default" state.
MOExtendedMenuItem is a subclass of NSMenuItem that adds support for a "default" state. This helps to solve the problem of what happens to menus that change title or other properties via validation methods when there's sometimes no valid target for the items.
Returns the default image.
Returns the default key equivalent.
Returns the default key equivalent modifier mask.
Returns the default state.
Returns the default title.
Enables automatic use of MOExtendedMenuItem. When it is enabled, all menus and menu items unarchived from nib files will use the MOExtendedMenuItem and MOExtendedMenu subclasses.
Returns whether automatic use of MOExtendedMenuItem is enabled. When it is enabled, all menus and menu items unarchived from nib files will use the MOExtendedMenuItem and MOExtendedMenu subclasses.
Restores the item to its default state. This is called for each item in a MOExtendedMenu at the beginning of each -update.
Sets the default image.
Sets the default key equivalent.
Sets the default key equivalent modifier mask.
Sets the default state.
Sets the default title.
(Last Updated 3/20/2005)
For example, you might have a "Save" command that sends a -saveDocument: action to the first responder. Wouldn't it be cool if the menu item actually said "Save
MOExtendedMenuItem and MOExtendedMenu cooperate to prevent this. MOExtendedMenuItem has a -defaultTitle (as well as other default state). MOExtendedMenu will revert each item in it to the default state at the beginning of its -update method. If a -validateMenuItem: changes it again, cool, but if not, the default state sticks.
MOExtendedMenuItem will automatically set its default state during awakeFromNib. So all you have to do is make sure that your menu items have their generic default state in your main nib.
You can use MOExtendedMenuItem in a couple ways. You could individually mark your menus and items in a nib file as being the MOExtendedMenuItem and MOExtendedMenu subclasses. Or you can simply call +[MOExtendedMenuItem enableRevertToDefaultItemState] in your application's main() before calling NSApplicationMain and it will arrange to have everything work automatically.
Methods
defaultImage
Returns the default image.
- ( NSImage *) defaultImage;
defaultKeyEquivalent
Returns the default key equivalent.
- ( NSString *) defaultKeyEquivalent;
defaultKeyEquivalentModifierMask
Returns the default key equivalent modifier mask.
- ( unsigned int ) defaultKeyEquivalentModifierMask;
defaultState
Returns the default state.
- ( int ) defaultState;
defaultTitle
Returns the default title.
- ( NSString *) defaultTitle;
enableRevertToDefaultItemState
Enables automatic use of MOExtendedMenuItem.
+ ( void ) enableRevertToDefaultItemState;
isRevertToDefaultItemStateEnabled
Returns whether automatic use of MOExtendedMenuItem is enabled.
+ ( BOOL ) isRevertToDefaultItemStateEnabled;
resetToDefaults
Restores the item to its default state.
- ( void ) resetToDefaults;
setDefaultImage:
Sets the default image.
- ( void ) setDefaultImage:
(NSImage *) newDefaultImage;
Parameter Descriptions
setDefaultKeyEquivalent:
Sets the default key equivalent.
- ( void ) setDefaultKeyEquivalent:
(NSString *) newDefaultKeyEquivalent;
Parameter Descriptions
setDefaultKeyEquivalentModifierMask:
Sets the default key equivalent modifier mask.
- ( void ) setDefaultKeyEquivalentModifierMask:
(unsigned int ) newDefaultKeyEquivalentModifierMask;
Parameter Descriptions
setDefaultState:
Sets the default state.
- ( void ) setDefaultState:
(int ) newDefaultState;
Parameter Descriptions
setDefaultTitle:
Sets the default title.
- ( void ) setDefaultTitle:
(NSString *) title;
Parameter Descriptions