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
Var FileDot, FileDiamond as MenuItem

FileDot.enable
FileDot.checked = true

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

FileDiamond.enable
FileDiamond.checked = true

// via function
Var 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
Var m as NSMenuItemMBS = NSMenuItemMBS.MenuItem(EditMenu)

// add the header
Var 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.
Var 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)

NSMenuItemMBS.writingToolsItems as NSMenuItemMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Menus MBS MacBase Plugin 25.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
An array of standard menu items related to Writing Tools.
Example
var items() as NSMenuItemMBS = NSMenuItemMBS.writingToolsItems
var item as NSMenuItemMBS = items(0)
var submenu as NSMenuMBS = item.submenu
var entry as NSMenuItemMBS = submenu.Item(0)

Break // see in debugger

Each call to this method returns an array of newly allocated instances of NSMenuItemMBS.
Requires macOS 15.2 or newer.

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


The biggest plugin in space...