Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSMenuMBS class.

NSMenuMBS.helpMenu as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 14.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the help menu if one is registered.

NSMenuMBS.mainMenu as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 14.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the main menu.

NSMenuMBS.menuBarVisible as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a Boolean value that indicates whether the menu bar is visible.

Available in Mac OS X v10.2 and later.
Returns true if the menu bar is visible, otherwise false.

NSMenuMBS.NSMenuDidAddItemNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

Posted after a menu item is added to the menu. The notification object is the instance of NSMenuMBS that just added the new menu item.
This is very useful to customize the menu in Xojo. The runtime rebuilds menu bar often, so you can catch it and edit menu.

The userInfo dictionary contains the following information:
NSMenuItemIndex: An integer index of the menu item that was added.

Some examples using this method:

NSMenuMBS.NSMenuDidBeginTrackingNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Posted when menu tracking begins. The notification object is the main menu bar (NSApplicationMBS mainMenu) or the root menu of a popup button. This notification does not contain a userInfo dictionary.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

NSMenuMBS.NSMenuDidChangeItemNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

Posted after a menu item in the menu changes appearance. Changes include enabling/disabling, changes in state, and changes to title. The notification object is the instance of NSMenuMBS with the menu item that changed. The userInfo dictionary contains the following information:

KeyValue
NSMenuItemIndexAn integer index of the menu item that changed.

NSMenuMBS.NSMenuDidEndTrackingNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

Posted when menu tracking ends, even if no action is sent. The notification object is the main menu bar (NSApplicationMBS mainMenu) or the root menu of a popup button. This notification does not contain a userInfo

NSMenuMBS.NSMenuDidRemoveItemNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

Posted after a menu item is removed from the menu. The notification object is the instance of NSMenu that just removed the menu item. The userInfo dictionary contains the following information:

NSMenuItemIndex: An integer index of the menu item that was removed. Note that this index may no longer be valid and in any event no longer points to the menu item that was removed.

NSMenuMBS.NSMenuDidSendActionNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

Posted just after the application dispatches a menu item's action method to the menu item's target. The notification object is the instance of NSMenuMBS containing the chosen menu item. The userInfo dictionary contains the following information:

KeyValue
MenuItemThe menu item that was chosen.

NSMenuMBS.NSMenuWillSendActionNotification as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
One of the notifications sent for menus.

Use this constant with NSNotificationObserverMBS class to get an event when such a notification is sent.

Posted just before the application dispatches a menu item's action method to the menu item's target. The notification object is the instance of NSMenuMBS containing the chosen menu item. The userInfo dictionary contains the following information:

KeyValue
MenuItemThe menu item that was chosen.

NSMenuMBS.paletteMenuWithColors(colors() as NSColorMBS, itemTitles() as String, templateImage as NSImageMBS = nil) as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 23.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates an palette menu displaying user-selectable color tags using the provided template image, tinted using the specified array of colors.
Example
dim m as NSMenuItemMBS = NSMenuItemMBS.MenuItem(EditMenu)

// gather data for menu
dim colors() as NSColorMBS
colors.Append NSColorMBS.whiteColor
colors.Append NSColorMBS.redColor
colors.Append NSColorMBS.blueColor

dim titles() as string = array("White", "Red", "Blue")

// now create palette and attach our handler
paletteMenu = NSMenuMBS.paletteMenuWithColors(Colors, titles)
AddHandler paletteMenu.PaletteSelectionChange, WeakAddressOf PaletteSelectionChange

// now make a dummy menu and add palette
dim n as new MyNSMenuItemMBS("Hello")
n.Enabled = true
n.submenu = paletteMenu
m.submenu.addItem n
self.HelloMenu = n

Optionally allows observing changes to the selection state in the compact menu. The block is invoked after the selection has been updated. Currently selected items can be retrieved from the `selectedItems` property.

Returns a palette menu.

Requires macOS Sonoma or newer.

Some examples using this method:

NSMenuMBS.popUpContextMenu(menu as NSMenuMBS, theEvent as NSEventMBS, view as NSViewMBS, font as NSFontMBS = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Displays a contextual menu over a view for an event using a specified font.

menu: The menu object to use for the contextual menu.
event: An NSEvent object representing the event.
view: The view object over which to display the contextual menu.
font: An NSFont object representing the font for the contextual menu. If you pass in nil for the font, the method uses the default font for menu.

Specifying a font using the font parameter is discouraged. Instead set the menu’s font using the setFont: method and pass nil for the font parameter.

Some examples using this method:

NSMenuMBS.setMenuBarVisible(value as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Sets whether the menu bar is visible and selectable by the user.

value: true if menu bar is to be visible, otherwise false.
Available in Mac OS X v10.2 and later.

NSMenuMBS.windowsMenu as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 14.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the window menu if one is registered.

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


The biggest plugin in space...