Class

NSMenuItem

A command item in an app menu.

Declaration

@interface NSMenuItem : NSObject

Overview

The NSMenuItem class includes some private functionality needed to maintain binary compatibility with other components of Cocoa. Because of this fact, you cannot replace the NSMenuItem class with a different class, but you can subclass it if necessary.

Topics

Creating a Menu Item

- initWithTitle:action:keyEquivalent:

Returns an initialized instance of NSMenuItem.

Enabling a Menu Item

enabled

A Boolean value that indicates whether the menu item is enabled.

Managing Hidden Status

hidden

A Boolean value that indicates whether the menu item is hidden.

hiddenOrHasHiddenAncestor

A Boolean value that indicates whether the menu item or any of its superitems is hidden.

Managing the Target and Action

target

The menu item's target.

action

The menu item's action-method selector.

Managing the Title

title

The menu item's title.

attributedTitle

A custom string for a menu item.

Managing the Tag

tag

The menu item's tag.

Managing the State

state

The state of the menu item.

Managing the Image

image

The menu item’s image.

onStateImage

The image of the menu item that indicates an “on” state.

offStateImage

The image of the menu item that indicates an “off” state.

mixedStateImage

The image of the menu item that indicates a “mixed” state, that is, a state neither “on” nor “off.”

Managing Submenus

submenu

The submenu of the menu item.

hasSubmenu

A Boolean value that indicates whether the menu item has a submenu.

parentItem

The menu item whose submenu contains the receiver.

Getting a Separator Item

separatorItem

A menu item that is used to separate logical groups of menu commands.

+ separatorItem

Returns a menu item that is used to separate logical groups of menu commands.

Managing the Owning Menu

menu

The menu item’s menu.

Managing Key Equivalents

keyEquivalent

The menu item’s unmodified key equivalent.

keyEquivalentModifierMask

The menu item’s keyboard equivalent modifiers.

Managing Mnemonics

- setMnemonicLocation:

Sets the character of the menu item title at location that is to be underlined.

Deprecated
- mnemonicLocation

Returns the position of the underlined character in the menu item title used as a mnemonic.

Deprecated
- setTitleWithMnemonic:

Sets the title of a menu item with a character denoting an access key.

Deprecated
- mnemonic

Returns the character in the menu item title that appears underlined for use as a mnemonic.

Deprecated

Managing User Key Equivalents

usesUserKeyEquivalents

Returns a Boolean value that indicates whether menu items conform to user preferences for key equivalents.

userKeyEquivalent

The user-assigned key equivalent for the menu item.

Managing Alternates

alternate

A Boolean value that marks the menu item as an alternate to the previous menu item.

Managing Indentation Levels

indentationLevel

The menu item indentation level for the menu item.

Managing Tool Tips

toolTip

A help tag for the menu item.

Representing an Object

representedObject

The object represented by the menu item.

Managing the View

view

The content view for the menu item.

Getting Highlighted Status

highlighted

A Boolean value that indicates whether the menu item should be drawn highlighted.

Initializers

See Also

Menus

NSMenu

An object that manages an app’s menus.

NSMenuDelegate

The optional methods implemented by delegates of NSMenu objects to manage menu display and handle some events.