Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSMenuItemMBS class.

NSMenuItemMBS.clearAction

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 20.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Clears action event.

Call this method once to have a menuitem which has no action.

NSMenuItemMBS.Constructor(DesktopMenuitem as DesktopMenuitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 22.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a new NSMenuItemMBS object for a given MenuItem.

May raise UnsupportedOperationException or NilObjectException if used incorrectly.

See also:

NSMenuItemMBS.Constructor(Handle as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Constructor for creating an instanced based on an existing handle.
Example
dim m as MenuItem = EditCopy
dim h as Integer = m.Handle(MenuItem.HandleType.CocoaNSMenuItem)
dim i as new NSMenuItemMBS(h)

i.Title = "Hello"

Useful if you get a NSMenuItem reference from a declare.
The object is retained.

See also:

NSMenuItemMBS.Constructor(MenuItem as MenuItem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 18.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a new NSMenuItemMBS object for a given MenuItem.
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")

May raise UnsupportedOperationException or NilObjectException if used incorrectly.

See also:

NSMenuItemMBS.Constructor(Other as NSMenuItemMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 22.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a new NSMenuItemMBS object referencing same NSMenuItem with a new Xojo object.

See also:

NSMenuItemMBS.Constructor(title as string="", keyEquivalent as string="")

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

Handle is not 0 after this call if it was successfull.
name and charcode are optional and can be "".
Charcode is the initial keyEquivalent for this menu item.
You can set the KeyEquivalentModifierMask to get different modifier keys.

See also:

NSMenuItemMBS.CreateMenuItem(title as string="", keyEquivalent as string="")

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

Handle is not 0 after this call if it was successfull.
name and charcode are optional and can be "".
Charcode is the initial keyEquivalent for this menu item.
You can set the KeyEquivalentModifierMask to get different modifier keys.

Deprecated, please use the Constructor instead.

Some examples using this method:

NSMenuItemMBS.setAction(target as NSResponderMBS, selectorName as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 23.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Sets the target for the menu action.
Example

dim n as NSMenuItemMBS // your menu item

n.setAction(window1.NSWindowMBS, "performClose:")

Please make sure the selector is correct as otherwise you get an exception later.
And make sure the target object stays alive.

NSMenuItemMBS.setTitleWithMnemonic(title as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Menus MBS MacBase Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Sets the title of a menu item with a character denoting an access key.

Use an ampersand character to mark the character (the one following the ampersand) to be designated.
Deprecated by Apple.

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


The biggest plugin in space...