Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSPopUpButtonMBS class.
NSPopUpButtonMBS.addItemsWithTitles(titles() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
temTitles: 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.
If you want to move an item, it's better to invoke removeItemWithTitle: explicitly and then send this method. After adding the items, this method uses the synchronizeTitleAndSelectedItem method to make sure the item being displayed matches the currently selected item.
Since 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. Add items directly to the receiver's menu instead.
NSPopUpButtonMBS.addItemWithTitle(title as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
title: The title of the menu-item entry. If an item with the same title already exists in the menu, the existing item is removed and the new one is added.
If you want to move an item, it's better to invoke removeItemWithTitle explicitly and then send this method. After adding the item, this method calls the synchronizeTitleAndSelectedItem method to make sure the item being displayed matches the currently selected item.
Since 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. Add items directly to the receiver's menu instead.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
On success the handle property is not zero.
See also:
NSPopUpButtonMBS.Constructor(Handle as Integer)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
The handle is casted to a NSPopUpButton and the plugin retains this handle.
See also:
NSPopUpButtonMBS.Constructor(left as Double, top as Double, width as Double, height as Double)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
On success the handle property is not zero.
See also:
NSPopUpButtonMBS.Constructor(left as Double, top as Double, width as Double, height as Double, pullsDown as boolean)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
left,top,width,height: The frame rectangle for the button, specified in the parent view's coordinate system.
pullsDown: true if you want the receiver to display a pull-down menu; otherwise, false if you want it to display a pop-up menu.
See also:
NSPopUpButtonMBS.indexOfItem(item as NSMenuItemMBS) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
item: The menu item whose index you want.
Returns the index of the item or -1 if no such item was found.
This method invokes the method of the same name of its NSPopUpButtonCell object.
NSPopUpButtonMBS.indexOfItemWithTag(tag as Integer) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
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.
This method invokes the method of the same name of its NSPopUpButtonCell object.
NSPopUpButtonMBS.indexOfItemWithTitle(title as string) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
title: The title of the item you want.
Returns the index of the item or -1 if no item with the specified title was found.
NSPopUpButtonMBS.indexOfSelectedItem as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
The index of the selected item, or -1 if no item is selected.
NSPopUpButtonMBS.insertItemWithTitle(title as string, atIndex as Integer)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
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.
If you want to move an item, it's better to invoke removeItemWithTitle: explicitly and then send this method. After adding the item, this method uses the synchronizeTitleAndSelectedItem method to make sure the item displayed matches the currently selected item.
Since 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. Add items directly to the receiver's menu instead.
NSPopUpButtonMBS.itemAtIndex(index as Integer) as NSMenuItemMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
index: The index of the item you want.
Returns the menu item, or nil if no item exists at the specified index.
NSPopUpButtonMBS.itemWithTitle(title as string) as NSMenuItemMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
title: The title of the menu item you want.
The menu item, or nil if no item with the specified title exists in the menu.
NSPopUpButtonMBS.lastItem as NSMenuItemMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
NSPopUpButtonMBS.removeAllItems
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
After removing the items, this method uses the synchronizeTitleAndSelectedItem method to refresh the menu.
NSPopUpButtonMBS.removeItemAtIndex(index as Integer)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
index: The zero-based index indicating which item to remove. Specifying 0 removes the item at the top of the menu.
After removing the item, this method uses the synchronizeTitleAndSelectedItem method to make sure the title displayed matches the currently selected item.
NSPopUpButtonMBS.removeItemWithTitle(title as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
title: The title of the item you want to remove. If no menu item exists with the specified title, this method triggers an assertion.
This method removes the first item it finds with the specified name. This method then uses synchronizeTitleAndSelectedItem to refresh the menu.
NSPopUpButtonMBS.selectedItem as NSMenuItemMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
Returns the menu item that is currently selected, or nil if no item is selected.
The last selected menu item is the one that was highlighted when the user released the mouse button. It is possible for a pull-down menu's selected item to be its first item.
(Read and Write computed property)
NSPopUpButtonMBS.selectItem(item as NSMenuItemMBS)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
item: The menu item to select, or nil if you want to deselect all menu items.
NSPopUpButtonMBS.selectItemAtIndex(index as Integer)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
index: The index of the item you want to select, or -1 you want to deselect all menu items.
NSPopUpButtonMBS.selectItemWithTag(tag as Integer) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
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 setTag: method of NSMenuItem.
Available in Mac OS X v10.4 and later.
NSPopUpButtonMBS.selectItemWithTitle(title as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
title: The title of the item to select. If you specify an empty string, or a string that does not match the title of a menu item, this method deselects the currently selected item.
NSPopUpButtonMBS.setTitle(title as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
If the receiver displays a pop-up menu, this method changes the current item to be the item with the specified title, adding a new item by that name if one does not already exist. If the receiver displays a pull-down list, this method sets its title to the specified string.
NSPopUpButtonMBS.synchronizeTitleAndSelectedItem
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
If there's no selected item, this method selects the first item in the item menu and sets the receiver's item to match. For pull-down menus, this method makes sure that the first item is being displayed (the NSPopUpButtonCell object must be set to use the selected menu item, which happens by default).
NSPopUpButtonMBS.titleOfSelectedItem as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Controls | MBS MacControls Plugin | 10.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
Returns the title of the selected menu item, or an empty string if no item is selected.
The items on this page are in the following plugins: MBS MacControls Plugin.