<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSMenu",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMenu"
  },
  "title" : "NSMenu"
}
-->

# NSMenu

An object that manages an app’s menus.

```
class NSMenu
```

## Topics

### Managing the Menu Bar

[`menuBarVisible()`](/documentation/AppKit/NSMenu/menuBarVisible())

Returns a Boolean value that indicates whether the menu bar is visible.

[`setMenuBarVisible(_:)`](/documentation/AppKit/NSMenu/setMenuBarVisible(_:))

Sets whether the menu bar is visible and selectable by the user.

[`menuBarHeight`](/documentation/AppKit/NSMenu/menuBarHeight)

The menu bar height for the main menu in pixels.

### Creating an NSMenu Object

[`init(title:)`](/documentation/AppKit/NSMenu/init(title:))

Initializes and returns a menu having the specified title and with autoenabling of menu items turned on.

[`init(coder:)`](/documentation/AppKit/NSMenu/init(coder:))

### Adding and Removing Menu Items

[`insertItem(_:at:)`](/documentation/AppKit/NSMenu/insertItem(_:at:))

Inserts a menu item into the menu at a specific location.

[`insertItem(withTitle:action:keyEquivalent:at:)`](/documentation/AppKit/NSMenu/insertItem(withTitle:action:keyEquivalent:at:))

Creates and adds a menu item at a specified location in the menu.

[`addItem(_:)`](/documentation/AppKit/NSMenu/addItem(_:))

Adds a menu item to the end of the menu.

[`addItem(withTitle:action:keyEquivalent:)`](/documentation/AppKit/NSMenu/addItem(withTitle:action:keyEquivalent:))

Creates a new menu item and adds it to the end of the menu.

[`removeItem(_:)`](/documentation/AppKit/NSMenu/removeItem(_:))

Removes a menu item from the menu.

[`removeItem(at:)`](/documentation/AppKit/NSMenu/removeItem(at:))

Removes the menu item at a specified location in the menu.

[`itemChanged(_:)`](/documentation/AppKit/NSMenu/itemChanged(_:))

Invoked when a menu item is modified visually (for example, its title changes).

[`removeAllItems()`](/documentation/AppKit/NSMenu/removeAllItems())

Removes all the menu items in the menu.

### Finding Menu Items

[`item(withTag:)`](/documentation/AppKit/NSMenu/item(withTag:))

Returns the first menu item in the menu with the specified tag.

[`item(withTitle:)`](/documentation/AppKit/NSMenu/item(withTitle:))

Returns the first menu item in the menu with a specified title.

[`item(at:)`](/documentation/AppKit/NSMenu/item(at:))

Returns the menu item at a specific location of the menu.

[`numberOfItems`](/documentation/AppKit/NSMenu/numberOfItems)

The number of menu items in the menu, including separator items.

[`items`](/documentation/AppKit/NSMenu/items)

An array containing the menu items in the menu.

### Finding Indices of Menu Items

[`index(of:)`](/documentation/AppKit/NSMenu/index(of:))

Returns the index identifying the location of a specified menu item in the menu.

[`indexOfItem(withTitle:)`](/documentation/AppKit/NSMenu/indexOfItem(withTitle:))

Returns the index of the first menu item in the menu that has a specified title.

[`indexOfItem(withTag:)`](/documentation/AppKit/NSMenu/indexOfItem(withTag:))

Returns the index of the first menu item in the menu identified by a tag.

[`indexOfItem(withTarget:andAction:)`](/documentation/AppKit/NSMenu/indexOfItem(withTarget:andAction:))

Returns the index of the first menu item in the menu that has a specified action and target.

[`indexOfItem(withRepresentedObject:)`](/documentation/AppKit/NSMenu/indexOfItem(withRepresentedObject:))

Returns the index of the first menu item in the menu that has a given represented object.

[`indexOfItem(withSubmenu:)`](/documentation/AppKit/NSMenu/indexOfItem(withSubmenu:))

Returns the index of the menu item in the menu with the given submenu.

### Managing Submenus

[`setSubmenu(_:for:)`](/documentation/AppKit/NSMenu/setSubmenu(_:for:))

Assigns a menu to be a submenu of the menu controlled by a given menu item.

[`submenuAction(_:)`](/documentation/AppKit/NSMenu/submenuAction(_:))

The action method assigned to menu items that open submenus.

[`attachedMenu`](/documentation/AppKit/NSMenu/attachedMenu)

Returns the menu currently attached to the menu.

[`isAttached`](/documentation/AppKit/NSMenu/isAttached)

Returns a Boolean value that indicates whether the menu is currently attached to another menu.

[`locationForSubmenu:`](/documentation/AppKit/NSMenu/locationForSubmenu:)

Returns the location in screen coordinates where the given submenu is displayed when opened as a submenu of the menu.

[`supermenu`](/documentation/AppKit/NSMenu/supermenu)

The parent menu that contains the menu as a submenu.

[`isTornOff`](/documentation/AppKit/NSMenu/isTornOff)

Indicates whether the menu is offscreen or attached to another menu (or if it’s the main menu).

### Enabling and Disabling Menu Items

[`autoenablesItems`](/documentation/AppKit/NSMenu/autoenablesItems)

Indicates whether the menu automatically enables and disables its menu items.

[`update()`](/documentation/AppKit/NSMenu/update())

Enables or disables the menu items of the menu based on the NSMenuValidation informal protocol and sizes the menu to fit its current menu items if necessary.

### Getting and Setting the Menu Font

[`font`](/documentation/AppKit/NSMenu/font)

The font of the menu and its submenus.

### Handling Keyboard Equivalents

[`performKeyEquivalent(with:)`](/documentation/AppKit/NSMenu/performKeyEquivalent(with:))

Performs the action for the menu item that corresponds to the given key equivalent.

### Simulating Mouse Clicks

[`performActionForItem(at:)`](/documentation/AppKit/NSMenu/performActionForItem(at:))

Causes the application to send the action message of a specified menu item to its target.

### Managing the Title

[`title`](/documentation/AppKit/NSMenu/title)

The title of the menu.

### Selecting Items

[`selectedItems`](/documentation/AppKit/NSMenu/selectedItems)

The menu items that are currently selected.

[`selectionMode`](/documentation/AppKit/NSMenu/selectionMode-swift.property)

The selection mode of the menu.

[`NSMenu.SelectionMode`](/documentation/AppKit/NSMenu/SelectionMode-swift.enum)

Describes how the menu manages selection states of the menu items that belong to the same selection group.

### Configuring Menu Size

[`minimumWidth`](/documentation/AppKit/NSMenu/minimumWidth)

The minimum width of the menu in screen coordinates.

[`size`](/documentation/AppKit/NSMenu/size)

The size of the menu in screen coordinates

[`sizeToFit`](/documentation/AppKit/NSMenu/sizeToFit)

Resizes the menu to exactly fit its items.

### Getting Menu Properties

[`propertiesToUpdate`](/documentation/AppKit/NSMenu/propertiesToUpdate)

The available properties for the menu.

### Managing Presentation Styles

[`presentationStyle`](/documentation/AppKit/NSMenu/presentationStyle-swift.property)

The presentation style of the menu.

[`NSMenu.PresentationStyle`](/documentation/AppKit/NSMenu/PresentationStyle-swift.enum)

Specifies the style of a menu.

### Working with Palettes

[`palette(colors:titles:template:onSelectionChange:)`](/documentation/AppKit/NSMenu/palette(colors:titles:template:onSelectionChange:))

Creates a palette style menu displaying user-selectable color tags that tint using the specified array of colors.

[`paletteMenuWithColors:titles:selectionHandler:`](/documentation/AppKit/NSMenu/paletteMenuWithColors:titles:selectionHandler:)

Creates a palette style menu displaying user-selectable color tags.

[`paletteMenuWithColors:titles:templateImage:selectionHandler:`](/documentation/AppKit/NSMenu/paletteMenuWithColors:titles:templateImage:selectionHandler:)

Creates a palette style menu displaying user-selectable color tags that tint using the specified array of colors.

### Managing Menu Change Notifications

[`menuChangedMessagesEnabled`](/documentation/AppKit/NSMenu/menuChangedMessagesEnabled)

Indicates whether messages are sent to the application’s windows each time the menu changes.

### Displaying Contextual Menus

[`allowsContextMenuPlugIns`](/documentation/AppKit/NSMenu/allowsContextMenuPlugIns)

Indicates whether the pop-up menu allows appending of contextual menu plug-in items.

### Displaying Context-Sensitive Help

[`popUpContextMenu(_:with:for:)`](/documentation/AppKit/NSMenu/popUpContextMenu(_:with:for:))

Displays a contextual menu over a view for an event.

[`popUpContextMenu(_:with:for:with:)`](/documentation/AppKit/NSMenu/popUpContextMenu(_:with:for:with:))

Displays a contextual menu over a view for an event using a specified font.

[`helpRequested(with:)`](/documentation/AppKit/NSMenu/helpRequested(with:))

Overridden by subclasses to implement specialized context-sensitive help behavior.

[`popUp(positioning:at:in:)`](/documentation/AppKit/NSMenu/popUp(positioning:at:in:))

Pops up the menu at the specified location.

### Managing Display of the State Column

[`showsStateColumn`](/documentation/AppKit/NSMenu/showsStateColumn)

Indicates whether the menu displays the state column.

### Controlling Allocation Zones

[`menuZone()`](/documentation/AppKit/NSMenu/menuZone())

Returns the zone from which `NSMenu` objects should be allocated.

[`setMenuZone:`](/documentation/AppKit/NSMenu/setMenuZone:)

Sets the zone from which `NSMenu` objects should be allocated

### Handling Highlighting

[`highlightedItem`](/documentation/AppKit/NSMenu/highlightedItem)

Indicates the currently highlighted item in the menu.

### Managing the User Interface

[`userInterfaceLayoutDirection`](/documentation/AppKit/NSMenu/userInterfaceLayoutDirection)

Configures the layout direction of menu items in the menu.

### Managing the Delegate

[`delegate`](/documentation/AppKit/NSMenu/delegate)

The delegate of the menu.

### Handling Tracking

[`cancelTracking()`](/documentation/AppKit/NSMenu/cancelTracking())

Dismisses the menu and ends all menu tracking.

[`cancelTrackingWithoutAnimation()`](/documentation/AppKit/NSMenu/cancelTrackingWithoutAnimation())

Dismisses the menu and ends all menu tracking without displaying the associated animation.

### Deprecated Methods

[`contextMenuRepresentation`](/documentation/AppKit/NSMenu/contextMenuRepresentation)

Deprecated.

[`setContextMenuRepresentation:`](/documentation/AppKit/NSMenu/setContextMenuRepresentation:)

Deprecated.

[`tearOffMenuRepresentation`](/documentation/AppKit/NSMenu/tearOffMenuRepresentation)

Deprecated.

[`setTearOffMenuRepresentation:`](/documentation/AppKit/NSMenu/setTearOffMenuRepresentation:)

Deprecated.

[`setMenuRepresentation:`](/documentation/AppKit/NSMenu/setMenuRepresentation:)

Deprecated.

[`menuRepresentation`](/documentation/AppKit/NSMenu/menuRepresentation)

Deprecated.

### Constants

[`NSMenu.Properties`](/documentation/AppKit/NSMenu/Properties)

These constants are used as a bitmask for specifying a set of menu or menu item properties, and are contained by the [`propertiesToUpdate`](/documentation/AppKit/NSMenu/propertiesToUpdate) property.

### Notifications

[`didAddItemNotification`](/documentation/AppKit/NSMenu/didAddItemNotification)

Posted after a menu item is added to the menu.

[`didChangeItemNotification`](/documentation/AppKit/NSMenu/didChangeItemNotification)

Posted after a menu item in the menu changes appearance.

[`didBeginTrackingNotification`](/documentation/AppKit/NSMenu/didBeginTrackingNotification)

Posted when menu tracking begins.

[`didEndTrackingNotification`](/documentation/AppKit/NSMenu/didEndTrackingNotification)

Posted when menu tracking ends, even if no action is sent.

[`didRemoveItemNotification`](/documentation/AppKit/NSMenu/didRemoveItemNotification)

Posted after a menu item is removed from the menu.

[`didSendActionNotification`](/documentation/AppKit/NSMenu/didSendActionNotification)

Posted just after the application dispatches a menu item’s action method to the menu item’s target.

[`willSendActionNotification`](/documentation/AppKit/NSMenu/willSendActionNotification)

Posted just before the application dispatches a menu item’s action method to the menu item’s target.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)