Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSPopUpButtonCellMBS class.

NSPopUpButtonCellMBS.addItemsWithTitles(itemTitles() as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds multiple items to the end of the menu.

itemTitles: An array of strings containing the titles of the items you want to add. Each string in the array should be unique. If an item with the same title already exists in the menu, the existing item is removed and the new one is added.

The new menu items use the pop-up button’s default action and target, but you can change these using the setAction: and setTarget: methods of the corresponding NSMenuItem object.

If you want to move an item, it’s better to invoke removeItemWithTitle: explicitly and then call this method. After adding the items, this method uses the synchronizeTitleAndSelectedItem method to make sure the item being displayed matches the currently selected item.

Because this method searches for duplicate items, it should not be used if you are adding items to an already populated menu with more than a few hundred items. In a situation like this, add items directly to the receiver's menu instead.

NSPopUpButtonCellMBS.addItemWithTitle(title as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Adds an item with the specified title to the end of the menu.

title: The title of the new menu item. If an item with the same title already exists in the menu, the existing item is removed and the new one is added.

The menu item uses the pop-up button’s default action and target, but you can change these using the setAction: and setTarget: methods of the corresponding NSMenuItemMBS object.
Because this method searches for duplicate items, it should not be used if you are adding an item to an already populated menu with more than a few hundred items. In a situation like this, add items directly to the button's menu instead.

NSPopUpButtonCellMBS.Constructor(image as NSImageMBS)   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The private constructor.

See also:

NSPopUpButtonCellMBS.Constructor(text as string, pullsDown as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns an NSPopUpButtonCell object initialized with the specified title.

See also:

NSPopUpButtonCellMBS.dismissPopUp

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Dismisses the pop-up button’s menu by ordering its window out.

If the pop-up button was not displaying its menu, this method does nothing.
You normally do not call this method explicitly. It is called by the Application Kit automatically to dismiss the menu for the pop-up button.

NSPopUpButtonCellMBS.indexOfItem(item as NSMenuItemMBS) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the index of the specified menu item.

item: The menu item whose index you want.

Returns the index of the item or -1 if no such item was found.

NSPopUpButtonCellMBS.indexOfItemWithTag(tag as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the index of the menu item with the specified tag.

tag: The tag of the menu item you want.

Returns the index of the item or -1 if no item with the specified tag was found.

Tags are values your application assigns to an object to identify it. You can assign tags to menu items using the tag property of NSMenuItemMBS.

NSPopUpButtonCellMBS.indexOfItemWithTitle(title as String) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the index of the item with the specified title.

title: The title of the item you want. You must not pass nil for this parameter.

Returns the index of the item or -1 if no item with the specified title was found.

NSPopUpButtonCellMBS.insertItemWithTitle(title as string, atIndex as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Inserts an item at the specified position in the menu.

title: The title of the new item. If an item with the same title already exists in the menu, the existing item is removed and the new one is added
index: The zero-based index at which to insert the item. Specifying 0 inserts the item at the top of the menu.

The value in index must represent a valid position in the array. The menu item at index and all those that follow it are shifted down one slot to make room for the new menu item.
This method assigns the pop-up button’s default action and target to the new menu item. This triggers the action event of the NSActionCellMBS.

Because this method searches for duplicate items, it should not be used if you are adding an item to an already populated menu with more than a few hundred items. In a situation like this, add items directly to the button's menu instead.

NSPopUpButtonCellMBS.itemArray as NSMenuItemMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
An array of NSMenuItemMBS objects that represent the items in the menu.

NSPopUpButtonCellMBS.itemAtIndex(Index as Integer) as NSMenuItemMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the menu item at the specified index.

index: The index of the item you want. The specified index must refer to an existing menu item.

Returns the menu item, or nil if no item exists at the specified index.

NSPopUpButtonCellMBS.itemTitleAtIndex(Index as Integer) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the title of the item at the specified index.

index: The index of the item you want.

Returns the title of the item, or an empty string if no item exists at the specified index.

NSPopUpButtonCellMBS.itemTitles as String()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
An array of strings containing the titles of every item in the menu.

The titles appear in the order in which the items appear in the menu. If the menu contains separator items, the array contains an empty string ("") for each separator item.

NSPopUpButtonCellMBS.itemWithTitle(title as String) as NSMenuItemMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the menu item with the specified title.

title: The title of the menu item you want.

Returns the menu item, or nil if no item with the specified title exists in the menu.

NSPopUpButtonCellMBS.removeAllItems

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes all items in the receiver’s item menu.

NSPopUpButtonCellMBS.removeItemAtIndex(Index as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes the item at the specified index.

index: The zero-based index indicating which item to remove. Specifying 0 removes the item at the top of the menu. The index must be valid and non-negative.

NSPopUpButtonCellMBS.removeItemWithTitle(title as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Removes the item with the specified title from the menu.

title: The title of the item you want to remove. If no menu item exists with the specified title, this method triggers an assertion.

NSPopUpButtonCellMBS.selectItem(item as NSMenuItemMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Selects the specified menu item.

item: The menu item to select, or nil if you want to deselect all menu items.

By default, selecting or deselecting a menu item from a pop-up menu changes its state. Selecting a menu item from a pull-down menu does not automatically alter the state of the item. To disassociate the current selection from the state of menu items, set the altersStateOfSelectedItem property to NO.

NSPopUpButtonCellMBS.selectItemAtIndex(Index as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Selects the item in the menu at the specified index.

index: The index of the item you want to select, or -1 you want to deselect all menu items.

By default, selecting or deselecting a menu item from a pop-up menu changes its state. Selecting a menu item from a pull-down menu does not automatically alter the state of the item. To disassociate the current selection from the state of menu items, set the altersStateOfSelectedItem property to false.
Subclassers can override this method to catch all select calls.

NSPopUpButtonCellMBS.selectItemWithTag(tag as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Selects the menu item with the specified tag.

tag: The tag of the item you want to select.

Returns true if the item was successfully selected; otherwise, false.

If no item with the specified tag is found, this method returns false and leaves the menu state unchanged.
You typically assign tags to menu items from Interface Builder, but you can also assign them programmatically using the tag property of NSMenuItemMBS.

NSPopUpButtonCellMBS.selectItemWithTitle(title as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Selects the item with the specified title.

title: The title of the item to select. If you specify nil, an empty string, or a string that does not match the title of a menu item, this method deselects the currently selected item.

By default, selecting or deselecting a menu item changes its state. To disassociate the current selection from the state of menu items, set the altersStateOfSelectedItem property to false.

NSPopUpButtonCellMBS.setTitle(title as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Sets the string displayed in the receiver when the user isn’t pressing the mouse button.

title: The string to display.

For pull-down menus that get their titles from a menu item, this method simply sets the pop-up button cell’s menu item to the first item in the menu. For pop-up menus, if a menu item whose title matches aString exists, this method makes that menu item the current selection; otherwise, it creates a new menu item with the title aString, adds it to the pop-up menu, and selects it.

NSPopUpButtonCellMBS.synchronizeTitleAndSelectedItem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Controls MBS MacCocoa Plugin 17.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Synchronizes the the pop-up button’s displayed item with the currently selected menu item.

If no item is currently selected, this method synchronizes the pop-up buttons displayed item with the first menu item. If the pop-up button cell does not get its displayed item from a menu item, this method does nothing.
For pull-down menus, this method sets the displayed item to the title first menu item.
If the pop-up button’s menu does not contain any menu items, this method sets the pop-up button’s displayed item to nil, resulting in nothing being displayed in the control.

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...