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

# NSPopUpButtonCell

The `NSPopUpButtonCell` class defines the visual appearance of pop-up buttons that display pop-up or pull-down menus. Pop-up menus present the user with a set of choices, much the way radio buttons do, but using much less space. Pull-down menus also provide a set of choices but present the information in a slightly different way, usually to provide a set of commands from which the user can choose.

```
class NSPopUpButtonCell
```

## Overview

The `NSPopUpButtonCell` class implements the user interface for the [`NSPopUpButton`](/documentation/AppKit/NSPopUpButton) class.

Changes made to a menu (such as adding, removing, or changing the items) are not apparent while the menu is being displayed or interacted with.

> Important: Setting a pop up button’s ``doc://com.apple.appkit/documentation/AppKit/NSCell/image`` property has no effect. The image displayed in a pop up button is taken from the selected menu item (in the case of a pop up menu) or from the first menu item (in the case of a pull-down menu).

## Topics

### Initialization

[`init(textCell:pullsDown:)`](/documentation/AppKit/NSPopUpButtonCell/init(textCell:pullsDown:))

Returns an `NSPopUpButtonCell` object initialized with the specified title.

### Accessing menu attributes

[`menu`](/documentation/AppKit/NSPopUpButtonCell/menu)

The pop-up button’s associated menu.

[`pullsDown`](/documentation/AppKit/NSPopUpButtonCell/pullsDown)

A Boolean value that indicates the behavior of the button’s menu.

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

A Boolean value that indicates if the button automatically enables and disables its items every time a user event occurs.

[`preferredEdge`](/documentation/AppKit/NSPopUpButtonCell/preferredEdge)

The edge of the cell from which the menu should pop out when screen conditions are restrictive.

[`usesItemFromMenu`](/documentation/AppKit/NSPopUpButtonCell/usesItemFromMenu)

A Boolean value that indicates if the control uses an item from the menu for its own title.

[`altersStateOfSelectedItem`](/documentation/AppKit/NSPopUpButtonCell/altersStateOfSelectedItem)

A Boolean value that indicates if the pop-up button links the state of the selected menu item to the current selection.

[`arrowPosition`](/documentation/AppKit/NSPopUpButtonCell/arrowPosition)

The position of the arrow displayed on the button.

### Adding and removing items

[`addItem(withTitle:)`](/documentation/AppKit/NSPopUpButtonCell/addItem(withTitle:))

Adds an item with the specified title to the end of the menu.

[`addItems(withTitles:)`](/documentation/AppKit/NSPopUpButtonCell/addItems(withTitles:))

Adds multiple items to the end of the menu.

[`insertItem(withTitle:at:)`](/documentation/AppKit/NSPopUpButtonCell/insertItem(withTitle:at:))

Inserts an item at the specified position in the menu.

[`removeItem(withTitle:)`](/documentation/AppKit/NSPopUpButtonCell/removeItem(withTitle:))

Removes the item with the specified title from the menu.

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

Removes the item at the specified index.

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

Removes all items in the receiver’s item menu.

### Accessing the items

[`itemArray`](/documentation/AppKit/NSPopUpButtonCell/itemArray)

An array of [`NSMenuItem`](/documentation/AppKit/NSMenuItem) objects that represent the items in the menu.

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

The number of items in the menu.

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

Returns the index of the specified menu item.

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

Returns the index of the item with the specified title.

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

Returns the index of the menu item with the specified tag.

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

Returns the index of the menu item that holds the specified represented object.

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

Returns the index of the menu item with the specified target and action.

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

Returns the menu item at the specified index.

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

Returns the menu item with the specified title.

[`lastItem`](/documentation/AppKit/NSPopUpButtonCell/lastItem)

The last item in the menu.

### Dealing with selection

[`select(_:)`](/documentation/AppKit/NSPopUpButtonCell/select(_:))

Selects the specified menu item.

[`selectItem(at:)`](/documentation/AppKit/NSPopUpButtonCell/selectItem(at:))

Selects the item in the menu at the specified index.

[`selectItem(withTag:)`](/documentation/AppKit/NSPopUpButtonCell/selectItem(withTag:))

Selects the menu item with the specified tag.

[`selectItem(withTitle:)`](/documentation/AppKit/NSPopUpButtonCell/selectItem(withTitle:))

Selects the item with the specified title.

[`setTitle(_:)`](/documentation/AppKit/NSPopUpButtonCell/setTitle(_:))

Sets the string displayed in the receiver when the user isn’t pressing the mouse button.

[`selectedItem`](/documentation/AppKit/NSPopUpButtonCell/selectedItem)

The menu item last selected by the user.

[`indexOfSelectedItem`](/documentation/AppKit/NSPopUpButtonCell/indexOfSelectedItem)

The index of the item last selected by the user.

[`synchronizeTitleAndSelectedItem()`](/documentation/AppKit/NSPopUpButtonCell/synchronizeTitleAndSelectedItem())

Synchronizes the pop-up button’s displayed item with the currently selected menu item.

### Title conveniences

[`itemTitle(at:)`](/documentation/AppKit/NSPopUpButtonCell/itemTitle(at:))

Returns the title of the item at the specified index.

[`itemTitles`](/documentation/AppKit/NSPopUpButtonCell/itemTitles)

An array of `NSString` objects containing the titles of every item in the menu.

[`titleOfSelectedItem`](/documentation/AppKit/NSPopUpButtonCell/titleOfSelectedItem)

The title of the item last selected by the user.

### Handling events and action messages

[`attachPopUp(withFrame:in:)`](/documentation/AppKit/NSPopUpButtonCell/attachPopUp(withFrame:in:))

Sets up the receiver to display a menu.

[`dismissPopUp()`](/documentation/AppKit/NSPopUpButtonCell/dismissPopUp())

Dismisses the pop-up button’s menu by ordering its window out.

[`performClick(withFrame:in:)`](/documentation/AppKit/NSPopUpButtonCell/performClick(withFrame:in:))

Displays the receiver’s menu and track mouse events in it.

### Constants

[`NSPopUpButton.ArrowPosition`](/documentation/AppKit/NSPopUpButton/ArrowPosition)

These constants are defined for use with the [`arrowPosition`](/documentation/AppKit/NSPopUpButtonCell/arrowPosition) property.

### Notifications

[`willPopUpNotification`](/documentation/AppKit/NSPopUpButtonCell/willPopUpNotification)

This notification is posted just before a pop-up menu is attached to its window frame.

### Initializers

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



---

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)