Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSMenuItemMBS class.

NSMenuItemMBS.MenuItem(DesktopMenuItem as DesktopMenuItem) as NSMenuItemMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 22.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries NSMenuItemMBS for a given menu item.

Returns nil on any error.

See also:

NSMenuItemMBS.MenuItem(MenuItem as MenuItem) as NSMenuItemMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 18.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries NSMenuItemMBS for a given menu item.
Example
dim FileDot, FileDiamond as MenuItem

FileDot.enable
FileDot.checked = true

// via constructor
dim n1 as new NSMenuItemMBS(fileDot)
n1.onStateImage = NSImageMBS.imageNamed("NSMenuItemBullet")

FileDiamond.enable
FileDiamond.checked = true

// via function
dim n2 as NSMenuItemMBS = NSMenuItemMBS.MenuItem(FileDiamond)
n2.onStateImage = NSImageMBS.imageNamed("NSMenuItemDiamond")

Returns nil on any error.

See also:

NSMenuItemMBS.sectionHeaderWithTitle(Title as String) as NSMenuItemMBS

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 a menu item representing a section header with the provided title.
Example
dim m as NSMenuItemMBS = NSMenuItemMBS.MenuItem(EditMenu)

// add the header
dim h as NSMenuItemMBS = NSMenuItemMBS.sectionHeaderWithTitle("Section Header")
h.Enabled = true
m.submenu.addItem h
self.SectionHeader = h

// and the new entry with our MyNSMenuItemMBS class to handle validate and action.
dim n as new MyNSMenuItemMBS("Hello")
n.Enabled = true
m.submenu.addItem n
self.HelloMenu = n // keep references

Section header items are used to provide context to a grouping of menu items.
Items created using this method are non-interactive and do not perform an action.

Requires macOS Sonoma or newer.

Some examples using this method:

NSMenuItemMBS.separatorItem as NSMenuItemMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a new separator menu item.

Some examples using this method:

NSMenuItemMBS.usesUserKeyEquivalents as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Whether menu items conform to user preferences for key equivalents.

If true, menu items conform to user preferences for key equivalents; if false, the key equivalents originally assigned to the menu items are used.
(Read and Write computed property)

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


The biggest plugin in space...