Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSMenuItemMBS class.

NSMenuItemMBS.ActionSelector as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the name of the objective-c method called for this menu event.

You can use this to find menu items by their selector. Which is often more save than by index or title.
(Read only property)

NSMenuItemMBS.Alternate as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Whether this menu item is an alternate to the previous menu item.

Available in Mac OS X v10.3 and later.
(Read and Write property)

NSMenuItemMBS.attributedTitle as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Specifies a custom string for a menu item.

You can use this method to add styled text and embedded images to menu item strings. If you do not set a text color for the attributed string, it is black when not selected, white when selected, and gray when disabled. Colored text remains unchanged when selected.

When you call this method to set the menu title to an attributed string, the setTitle: method is also called to set the menu title with a plain string. If you clear the attributed title, the plain title remains unchanged.
(Read and Write property)

NSMenuItemMBS.Enabled as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Whether this menuitem is enabled.

(Read and Write property)

NSMenuItemMBS.Handle as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The reference to the NSMenuItem object used internally.

(Read and Write property)

NSMenuItemMBS.hasSubmenu as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns true if the menuitem has a submenu, false if it doesn't.

(Read only property)

Some examples using this property:

NSMenuItemMBS.Identifier as String   New in 24.1

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 24.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
A string that identifies this user interface item.

It should be set to a unique value on NSViews when they are intended to be used inside a view-based NSTableView. Identifiers should be unique per-window. For programmatically created user interface items, you would typically set this value in code after creating a view but before adding it to a window. You may also want to set an identifier on a window, after creating it programmatically, to identify the window easily when it is reopened. You should not change the identifier after a view is added to a window. Identifiers beginning with an underscore are reserved for the system. In framework classes that implement this protocol, the accessor methods are not intended to be overridden.

To help avoid collision of identifiers, it is recommended that identifiers use the same prefix as is used for the framework or application. For example, identifiers for standard AppKit interface items, such as the open panel, will begin with "NS".

The slash '/', backslash '\', and colon ':' characters are reserved and should not be used in identifiers.
(Read and Write property)

NSMenuItemMBS.image as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The image displayed by the menuitem, or nil if it displays no image.

(Read and Write property)

NSMenuItemMBS.indentationLevel as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The menu item indentation level for the menu item.

The value will be from 0 to 15. The default indentation level is 0.
Available in Mac OS X v10.3 and later.
(Read and Write property)

NSMenuItemMBS.isHidden as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a Boolean value that indicates whether the menuitem is hidden.

Mac OS X 10.5 only.
Returns true if the receiver is hidden, otherwise false.
This value can be set to hide or show a menuitem.
(Read and Write property)

NSMenuItemMBS.isHiddenOrHasHiddenAncestor as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a Boolean value that indicates whether the menuitem or any of its superitems is hidden.

Mac OS X 10.5 only.
Returns true if the receiver or any of its superitems is hidden, otherwise false.
(Read only property)

NSMenuItemMBS.isHighlighted as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns a Boolean value that indicates whether the receiver should be drawn highlighted.

Returns true if the receiver should be drawn highlighted, otherwise false.
Mac OS X 10.5 only.
(Read only property)

NSMenuItemMBS.isSectionHeader as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 23.5 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Indicates whether the item is a section header.

Section header items are created using the sectionHeader() class method.

Requires macOS Sonoma or newer.
(Read only property)

NSMenuItemMBS.isSeparatorItem as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns whether the receiver is a separator item (that is, a menu item used to visually segregate related menu items).

(Read only property)

NSMenuItemMBS.keyEquivalent as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The receiver's unmodified keyboard equivalent, or the empty string if one hasn't been defined.
Example
dim m as new NSMenuItemMBS
m.CreateMenuItem "Hello"
m.keyEquivalent = "a" // A
m.keyEquivalent = "A" // shift-A

Use keyEquivalentModifierMask to determine the modifier mask for the key equivalent. In the current implementation "A" can be interpreted as Shift-A by the system even without the shift in the mask.
(Read and Write property)

NSMenuItemMBS.keyEquivalentModifierMask as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
the menu item's keyboard equivalent modifier mask.
Example
const NSShiftKeyMask=131072
const NSControlKeyMask=262144
const NSAlternateKeyMask=524288
const NSCommandKeyMask=1048576

dim d as new NSMenuItemMBS
d.CreateMenuItem "Last menu entry",""
d.Enabled=true
d.KeyEquivalent="A"
d.KeyEquivalentModifierMask=NSShiftKeyMask+NSCommandKeyMask+NSAlternateKeyMask // command-option-shift

Constants for the mask:

NSAlphaShiftKeyMask = 65536
Set if Caps Lock key is pressed.
Available in Mac OS X v10.0 and later.

NSShiftKeyMask = 131072
Set if Shift key is pressed.
Available in Mac OS X v10.0 and later.

NSControlKeyMask = 262144
Set if Control key is pressed.
Available in Mac OS X v10.0 and later.

NSAlternateKeyMask = 524288
Set if Option or Alternate key is pressed.
Available in Mac OS X v10.0 and later.

NSCommandKeyMask = 1048576
Set if Command key is pressed.
Available in Mac OS X v10.0 and later.

NSNumericPadKeyMask = 2097152
Set if any key in the numeric keypad is pressed. The numeric keypad is generally on the right side of the keyboard. This is also set if any of the arrow keys are pressed (NSUpArrowFunctionKey, NSDownArrowFunctionKey, NSLeftArrowFunctionKey, and NSRightArrowFunctionKey).
Available in Mac OS X v10.0 and later.

NSHelpKeyMask = 4194304
Set if the Help key is pressed.
Available in Mac OS X v10.0 and later.

NSFunctionKeyMask = 8388608
Set if any function key is pressed. The function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys).
Available in Mac OS X v10.0 and later.

NSDeviceIndependentModifierFlagsMask = 16777216
Used to retrieve only the device-independent modifier flags, allowing applications to mask off the device-dependent modifier flags, including event coalescing information.
Available in Mac OS X v10.4.
(Read and Write property)

NSMenuItemMBS.menu as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The menu where this menu item is inside.

nil if no menu belongs to this menuitem.
(Read only property)

NSMenuItemMBS.mixedStateImage as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The image used to depict a "mixed state."

A mixed state is useful for indicating "off" and "on" attribute values in a group of selected objects, such as a selection of text containing bold and plain (nonbolded) words.
(Read and Write property)

NSMenuItemMBS.offStateImage as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The image used to depict the receiver's "off" state, or nil if the image has not been set.

By default, there is no off state image.
(Read and Write property)

NSMenuItemMBS.onStateImage as NSImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The image of the receiver that indicates an "on" state.

The Image object to use for the "on" state of the menu item. If itemImage is nil, any current on-state image is removed.
(Read and Write property)

Some examples using this property:

NSMenuItemMBS.parentItem as NSMenuItemMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Returns the menu item whose submenu contains the receiver.

Returns the parent menu item, or nil if the receiver does not have a parent item.
Available in Mac OS X v10.6 and later.
(Read only property)

NSMenuItemMBS.state as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The state of the menuitem.

An integer constant representing a state; it should be one of NSOffState, NSOnState, or NSMixedState.
Same as Checked property on Xojo's menu items.

Constants:
NSMixedState = -1The corresponding feature is in effect somewhere.
NSOffState = 0The corresponding feature is in effect nowhere.
NSOnState = 1The corresponding feature is in effect everywhere.
(Read and Write property)

NSMenuItemMBS.submenu as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The submenu attached to this menuitem.

nil if there is no submenu.
(Read and Write property)

Some examples using this property:

NSMenuItemMBS.tag as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The menu item tag value.

You can use this value as you like.

If you need to store more custom data than just an integer, you should subclass the NSMenuItemMBS class and add properties as needed.
(Read and Write property)

NSMenuItemMBS.Title as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The title of the menu item.

(Read and Write property)

NSMenuItemMBS.toolTip as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The help tag for a menu item.

(Read and Write property)

NSMenuItemMBS.userKeyEquivalent as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The user-assigned key equivalent for the menu item.

(Read only property)

NSMenuItemMBS.view as NSViewMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Menus MBS MacBase Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The view to be used for this menuitem.

Using a view you can draw whatever you like in the menu item.
You can set it to nil to remove the view.
Requires Mac OS X 10.5.
(Read and Write property)

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


The biggest plugin in space...