Up

# NSMenuItem

### Authors

Ovidiu Predescu (`ovidiu@net-community.com`)
David Lazaro Saz (`khelekir@encomix.es`)

> The menu cell class.

Copyright: (C) 1996 Free Software Foundation, Inc.

### Contents -

1. Software documentation for the NSMenuItem class
2. Software documentation for the NSMenuItem(GNUstepExtra) category
3. Software documentation for the NSMenuItem protocol

# Software documentation for the NSMenuItem class

## NSMenuItem : NSObject

> Declared in:
>   AppKit/NSMenuItem.h

> Conforms to:
>   NSMenuItem
>   NSValidatedUserInterfaceItem

Availability: OpenStep
Description forthcoming.

Instance Variables

## Instance Variables for NSMenuItem Class

### _action

@protected SEL _action;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _changesState

@protected BOOL _changesState;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _enabled

@protected BOOL _enabled;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _image

@protected NSImage* _image;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _indentation

@protected char _indentation;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _isAlternate

@protected BOOL _isAlternate;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _keyEquivalent

@protected NSString* _keyEquivalent;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _keyEquivalentModifierMask

@protected unsigned int _keyEquivalentModifierMask;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _menu

@protected NSMenu* _menu;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _mixedStateImage

@protected NSImage* _mixedStateImage;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _mnemonicLocation

@protected unsigned int _mnemonicLocation;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _offStateImage

@protected NSImage* _offStateImage;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _onStateImage

@protected NSImage* _onStateImage;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _representedObject

@protected id _representedObject;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _state

@protected int _state;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _submenu

@protected NSMenu* _submenu;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _tag

@protected int _tag;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _target

@protected id _target;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _title

@protected NSString* _title;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _toolTip

@protected NSString* _toolTip;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

# Software documentation for the NSMenuItem(GNUstepExtra) category

## NSMenuItem(GNUstepExtra)

> Declared in:
>   AppKit/NSMenuItem.h

Availability: Not in OpenStep/MacOS-X
Description forthcoming.
Method summary

- -changesState
- -setChangesState:

### changesState

- (BOOL) changesState;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### setChangesState:

- (void) setChangesState: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

# Software documentation for the NSMenuItem protocol

## NSMenuItem

> Declared in:
>   AppKit/NSMenuItem.h

> Conforms to:
>   NSCopying
>   NSCoding
>   NSObject

Availability: OpenStep
Specifies the methods that an object must implement if it is to be placed in a menu as a menu item. The NSMenuItem class provides a reference implementation suitable for most uses.
Method summary

- +separatorItem
- +setUsesUserKeyEquivalents:
- +usesUserKeyEquivalents
- -action
- -attributedTitle
- -hasSubmenu
- -image
- -indentationLevel
- -initWithTitle:action:keyEquivalent:
- -isAlternate
- -isEnabled
- -isSeparatorItem
- -keyEquivalent
- -keyEquivalentModifierMask
- -menu
- -mixedStateImage
- -mnemonic
- -mnemonicLocation
- -offStateImage
- -onStateImage
- -representedObject
- -setAction:
- -setAlternate:
- -setAttributedTitle:
- -setEnabled:
- -setImage:
- -setIndentationLevel:
- -setKeyEquivalent:
- -setKeyEquivalentModifierMask:
- -setMenu:
- -setMixedStateImage:
- -setMnemonicLocation:
- -setOffStateImage:
- -setOnStateImage:
- -setRepresentedObject:
- -setState:
- -setSubmenu:
- -setTag:
- -setTarget:
- -setTitle:
- -setTitleWithMnemonic:
- -setToolTip:
- -state
- -submenu
- -tag
- -target
- -title
- -toolTip
- -userKeyEquivalent
- -userKeyEquivalentModifierMask

### separatorItem

+ (id<NSMenuItem>) separatorItem;
Availability: OpenStep

Returns a seperator. This is just a blank menu item which serves to divide the menu into seperate parts.

### setUsesUserKeyEquivalents:

+ (void) setUsesUserKeyEquivalents: (BOOL)flag;
Availability: OpenStep

Sets a flag that, when set to `YES`, objects of this class will use user defined key equivalents.

### usesUserKeyEquivalents

+ (BOOL) usesUserKeyEquivalents;
Availability: OpenStep

Returns a flag which indicates if the receiver will use user defined key equivalents.

### action

- (SEL) action;
Availability: OpenStep

Returns the action of the receiver.

### attributedTitle

- (NSAttributedString*) attributedTitle;
Availability: Not in OpenStep/MacOS-X

Returns the menu item's title as an attributed string.

### hasSubmenu

- (BOOL) hasSubmenu;
Availability: OpenStep

Returns a boolean indicating if the receiver has a sub menu.

### image

- (NSImage*) image;
Availability: OpenStep

Returns the image to be displayed in the receiver.

### indentationLevel

- (int) indentationLevel;
Availability: Not in OpenStep/MacOS-X

Returns the indentation level, a number between 0 and 15.

### initWithTitle: action: keyEquivalent:

- (id) initWithTitle: (NSString*)aString action: (SEL)aSelector keyEquivalent: (NSString*)charCode;
Availability: OpenStep

Initializes the receiver with aString as the title. The method called with the menu is selected is represented by aSelector. The key equivalent which can be used to invoke this menu item is represented by charCode.

### isAlternate

- (BOOL) isAlternate;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### isEnabled

- (BOOL) isEnabled;
Availability: OpenStep

Returns `YES` if the receiver is enabled.

### isSeparatorItem

- (BOOL) isSeparatorItem;
Availability: OpenStep

Returns a boolean indicating if the receiver is a separator.

### keyEquivalent

- (NSString*) keyEquivalent;
Availability: OpenStep

Returns the key equivalent of the receiver.

### keyEquivalentModifierMask

- (unsigned int) keyEquivalentModifierMask;
Availability: OpenStep

Returns the key equivalent mask.

### menu

- (NSMenu*) menu;
Availability: OpenStep

Returns the menu to which this menu item is connected.

### mixedStateImage

- (NSImage*) mixedStateImage;
Availability: OpenStep

Returns the image to be displayed when the receiver is in the "Mixed" state.

### mnemonic

- (NSString*) mnemonic;
Availability: OpenStep
Description forthcoming.

### mnemonicLocation

- (unsigned) mnemonicLocation;
Availability: OpenStep
Description forthcoming.

### offStateImage

- (NSImage*) offStateImage;
Availability: OpenStep

Returns the image to be displayed when the receiver is in the "Off" state.

### onStateImage

- (NSImage*) onStateImage;
Availability: OpenStep

Returns the image to be displayed when the receiver is in the "On" state.

### representedObject

- (id) representedObject;
Availability: OpenStep

Returns the object represented by the reciever.

### setAction:

- (void) setAction: (SEL)aSelector;
Availability: OpenStep

Sets the action as aSelector on the receiver.

### setAlternate:

- (void) setAlternate: (BOOL)isAlternate;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### setAttributedTitle:

- (void) setAttributedTitle: (NSAttributedString*)title;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### setEnabled:

- (void) setEnabled: (BOOL)flag;
Availability: OpenStep

Set the receiver to be enabled.

### setImage:

- (void) setImage: (NSImage*)menuImage;
Availability: OpenStep

Sets the image to be displayed in the receiver.

### setIndentationLevel:

- (void) setIndentationLevel: (int)level;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### setKeyEquivalent:

- (void) setKeyEquivalent: (NSString*)aKeyEquivalent;
Availability: OpenStep

Sets the key equivalent of the receiver.

### setKeyEquivalentModifierMask:

- (void) setKeyEquivalentModifierMask: (unsigned int)mask;
Availability: OpenStep

Sets the modfier for the key equivalent. These masks indicate if the key equivalent requires ALT, Control or other key modifiers.

### setMenu:

- (void) setMenu: (NSMenu*)menu;
Availability: OpenStep

Sets the menu which this item belongs to. This method does not retain the object represented by menu.

### setMixedStateImage:

- (void) setMixedStateImage: (NSImage*)image;
Availability: OpenStep

Sets the image to be displayed when the receiver is in the "Mixed" state.

### setMnemonicLocation:

- (void) setMnemonicLocation: (unsigned)location;
Availability: OpenStep
Description forthcoming.

### setOffStateImage:

- (void) setOffStateImage: (NSImage*)image;
Availability: OpenStep

Sets the image to be displayed when the receiver is in the "Off" state.

### setOnStateImage:

- (void) setOnStateImage: (NSImage*)image;
Availability: OpenStep

Sets the image to be displayed when the receiver is in the "On" state.

### setRepresentedObject:

- (void) setRepresentedObject: (id)anObject;
Availability: OpenStep

Sets the object represented by the reciever to anObject.

### setState:

- (void) setState: (int)state;
Availability: OpenStep

Sets the state of the the receiver.

### setSubmenu:

- (void) setSubmenu: (NSMenu*)submenu;
Availability: OpenStep

Sets the submenu of the receiver. This method does retain the submenu object.

### setTag:

- (void) setTag: (int)anInt;
Availability: OpenStep

Sets the tag of the reciever as anInt.

### setTarget:

- (void) setTarget: (id)anObject;
Availability: OpenStep

Sets the target as anObject on the receiver.

### setTitle:

- (void) setTitle: (NSString*)aString;
Availability: OpenStep

Sets the title of the menu, represented by aString.

### setTitleWithMnemonic:

- (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand;
Availability: OpenStep
Description forthcoming.

### setToolTip:

- (void) setToolTip: (NSString*)toolTip;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### state

- (int) state;
Availability: OpenStep

Returns the state of the receiver.

### submenu

- (NSMenu*) submenu;
Availability: OpenStep

Returns the attached submenu.

### tag

- (int) tag;
Availability: OpenStep

Returns the tag of the receiver.

### target

- (id) target;
Availability: OpenStep

Returns the target of the receiver.

### title

- (NSString*) title;
Availability: OpenStep

Returns the menu's title.

### toolTip

- (NSString*) toolTip;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### userKeyEquivalent

- (NSString*) userKeyEquivalent;
Availability: OpenStep

Returns the key equivalent defined by the users defaults.

### userKeyEquivalentModifierMask

- (unsigned int) userKeyEquivalentModifierMask;
Availability: OpenStep

Returns the user defined key equivalent modifier.

Up