NativeMenu
A server interface for OS native menus.
A server interface for OS native menus.
NativeMenu handles low-level access to the OS native global menu bar and popup menus.
Note: This is low-level API, consider using MenuBar with MenuBar.PreferGlobalMenu set to true, and PopupMenu with PopupMenu.PreferNativeMenu set to true.
To create a menu, use NativeMenu.CreateMenu, add menu items using add_*_item methods. To remove a menu, use NativeMenu.FreeMenu.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
SingletonProperty
public static NativeMenuInstance Singleton { get; }Methods71
AddCheckItemint
public static int AddCheckItem(Rid rid, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new checkable item with text label to the global menu rid.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
label | string | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddIconCheckItemint
public static int AddIconCheckItem(Rid rid, Texture2D icon, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new checkable item with text label and icon icon to the global menu rid.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
icon | Texture2D | — |
label | string | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddIconItemint
public static int AddIconItem(Rid rid, Texture2D icon, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new item with text label and icon icon to the global menu rid.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
icon | Texture2D | — |
label | string | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddIconRadioCheckItemint
public static int AddIconRadioCheckItem(Rid rid, Texture2D icon, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new radio-checkable item with text label and icon icon to the global menu rid.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See NativeMenu.SetItemChecked for more info on how to control it.
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
icon | Texture2D | — |
label | string | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddItemint
public static int AddItem(Rid rid, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new item with text label to the global menu rid.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
label | string | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddMultistateItemint
public static int AddMultistateItem(Rid rid, string label, int maxStates, int defaultState, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new item with text label to the global menu rid.
Contrarily to normal binary items, multistate items can have more than two states, as defined by max_states. Each press or activate of the item will increase the state by one. The default value is defined by default_state.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: By default, there's no indication of the current item state, it should be changed manually.
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
label | string | — |
maxStates | int | — |
defaultState | int | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddRadioCheckItemint
public static int AddRadioCheckItem(Rid rid, string label, Callable callback = default, Callable keyCallback = default, Variant tag = default, Key accelerator = Key.None, int index = -1);Adds a new radio-checkable item with text label to the global menu rid.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
An accelerator can optionally be defined, which is a keyboard shortcut that can be pressed to trigger the menu button even if it's not currently open. The accelerator is generally a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: Radio-checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See NativeMenu.SetItemChecked for more info on how to control it.
Note: The callback and key_callback Callables need to accept exactly one Variant parameter, the parameter passed to the Callables will be the value passed to tag.
Note: This method is implemented on macOS and Windows.
Note: On Windows, accelerator and key_callback are ignored.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
label | string | — |
callback | Callable | default |
keyCallback | Callable | default |
tag | Variant | default |
accelerator | Key | Key.None |
index | int | -1 |
intAddSeparatorint
public static int AddSeparator(Rid rid, int index = -1);Adds a separator between items to the global menu rid. Separators also occupy an index.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
index | int | -1 |
intAddSubmenuItemint
public static int AddSubmenuItem(Rid rid, string label, Rid submenuRid, Variant tag = default, int index = -1);Adds an item that will act as a submenu of the global menu rid. The submenu_rid argument is the RID of the global menu that will be shown when the item is clicked.
Returns index of the inserted item, it's not guaranteed to be the same as index value.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
label | string | — |
submenuRid | Rid | — |
tag | Variant | default |
index | int | -1 |
intClearvoid
public static void Clear(Rid rid);Removes all items from the global menu rid.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
CreateMenuRid
public static Rid CreateMenu();Creates a new global menu object. Note: This method is implemented on macOS and Windows.
RidFindItemIndexWithSubmenuint
public static int FindItemIndexWithSubmenu(Rid rid, Rid submenuRid);Returns the index of the item with the submenu specified by submenu_rid. Indices are automatically assigned to each item by the engine.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
submenuRid | Rid | — |
intFindItemIndexWithTagint
public static int FindItemIndexWithTag(Rid rid, Variant tag);Returns the index of the item with the specified tag. Indices are automatically assigned to each item by the engine.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
tag | Variant | — |
intFindItemIndexWithTextint
public static int FindItemIndexWithText(Rid rid, string text);Returns the index of the item with the specified text. Indices are automatically assigned to each item by the engine.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
text | string | — |
intFreeMenuvoid
public static void FreeMenu(Rid rid);Frees a global menu object created by this NativeMenu.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
GetItemAcceleratorKey
public static Key GetItemAccelerator(Rid rid, int idx);Returns the accelerator of the item at index idx. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
KeyGetItemCallbackCallable
public static Callable GetItemCallback(Rid rid, int idx);Returns the callback of the item at index idx.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
CallableGetItemCountint
public static int GetItemCount(Rid rid);Returns number of items in the global menu rid.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
intGetItemIconTexture2D
public static Texture2D GetItemIcon(Rid rid, int idx);Returns the icon of the item at index idx.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
Texture2DGetItemIndentationLevelint
public static int GetItemIndentationLevel(Rid rid, int idx);Returns the horizontal offset of the item at the given idx.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
intGetItemKeyCallbackCallable
public static Callable GetItemKeyCallback(Rid rid, int idx);Returns the callback of the item accelerator at index idx.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
CallableGetItemMaxStatesint
public static int GetItemMaxStates(Rid rid, int idx);Returns number of states of a multistate item. See NativeMenu.AddMultistateItem for details.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
intGetItemStateint
public static int GetItemState(Rid rid, int idx);Returns the state of a multistate item. See NativeMenu.AddMultistateItem for details.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
intGetItemSubmenuRid
public static Rid GetItemSubmenu(Rid rid, int idx);Returns the submenu ID of the item at index idx. See NativeMenu.AddSubmenuItem for more info on how to add a submenu.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
RidGetItemTagVariant
public static Variant GetItemTag(Rid rid, int idx);Returns the metadata of the specified item, which might be of any type. You can set it with NativeMenu.SetItemTag, which provides a simple way of assigning context data to items.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
VariantGetItemTextstring
public static string GetItemText(Rid rid, int idx);Returns the text of the item at index idx.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
stringGetItemTooltipstring
public static string GetItemTooltip(Rid rid, int idx);Returns the tooltip associated with the specified index idx.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
stringGetMinimumWidthfloat
public static float GetMinimumWidth(Rid rid);Returns global menu minimum width. Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
floatGetPopupCloseCallbackCallable
public static Callable GetPopupCloseCallback(Rid rid);Returns global menu close callback. Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
CallableGetPopupOpenCallbackCallable
public static Callable GetPopupOpenCallback(Rid rid);Returns global menu open callback. Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
CallableGetSizeVector2
public static Vector2 GetSize(Rid rid);Returns global menu size. Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
Vector2GetSystemMenuRid
public static Rid GetSystemMenu(NativeMenu.SystemMenus menuId);Returns RID of a special system menu. Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
menuId | NativeMenu.SystemMenus | — |
RidGetSystemMenuNamestring
public static string GetSystemMenuName(NativeMenu.SystemMenus menuId);Returns readable name of a special system menu. Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
menuId | NativeMenu.SystemMenus | — |
stringGetSystemMenuTextstring
public static string GetSystemMenuText(NativeMenu.SystemMenus menuId);Returns the text of the system menu item. Note: This method is implemented on macOS.
| Name | Type | Default |
|---|---|---|
menuId | NativeMenu.SystemMenus | — |
stringHasFeaturebool
public static bool HasFeature(NativeMenu.Feature feature);Returns true if the specified feature is supported by the current NativeMenu, false otherwise.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
feature | NativeMenu.Feature | — |
boolHasMenubool
public static bool HasMenu(Rid rid);Returns true if rid is valid global menu.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
boolHasSystemMenubool
public static bool HasSystemMenu(NativeMenu.SystemMenus menuId);Returns true if a special system menu is supported.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
menuId | NativeMenu.SystemMenus | — |
boolIsItemCheckablebool
public static bool IsItemCheckable(Rid rid, int idx);Returns true if the item at index idx is checkable in some way, i.e. if it has a checkbox or radio button.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
boolIsItemCheckedbool
public static bool IsItemChecked(Rid rid, int idx);Returns true if the item at index idx is checked.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
boolIsItemDisabledbool
public static bool IsItemDisabled(Rid rid, int idx);Returns true if the item at index idx is disabled. When it is disabled it can't be selected, or its action invoked.
See NativeMenu.SetItemDisabled for more info on how to disable an item.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
boolpublic static bool IsItemHidden(Rid rid, int idx);Returns true if the item at index idx is hidden.
See NativeMenu.SetItemHidden for more info on how to hide an item.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
boolIsItemIndeterminatebool
public static bool IsItemIndeterminate(Rid rid, int idx);Returns true if the item at index idx is indeterminate.
See NativeMenu.SetItemIndeterminate for more info on how to set an item.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
boolIsItemRadioCheckablebool
public static bool IsItemRadioCheckable(Rid rid, int idx);Returns true if the item at index idx has radio button-style checkability.
Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
boolIsOpenedbool
public static bool IsOpened(Rid rid);Returns true if the menu is currently opened.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
boolIsSystemMenubool
public static bool IsSystemMenu(Rid rid);Return true is global menu is a special system menu.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
boolPopupvoid
public static void Popup(Rid rid, Vector2I position);Shows the global menu at position in the screen coordinates.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
position | Vector2I | — |
RemoveItemvoid
public static void RemoveItem(Rid rid, int idx);Removes the item at index idx from the global menu rid.
Note: The indices of items after the removed item will be shifted by one.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
SetInterfaceDirectionvoid
public static void SetInterfaceDirection(Rid rid, bool isRtl);Sets the menu text layout direction from right-to-left if is_rtl is true.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
isRtl | bool | — |
SetItemAcceleratorvoid
public static void SetItemAccelerator(Rid rid, int idx, Key keycode);Sets the accelerator of the item at index idx. keycode can be a single Key, or a combination of KeyModifierMasks and Keys using bitwise OR such as KEY_MASK_CTRL | KEY_A ([kbd]Ctrl + A[/kbd]).
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
keycode | Key | — |
SetItemCallbackvoid
public static void SetItemCallback(Rid rid, int idx, Callable callback);Sets the callback of the item at index idx. Callback is emitted when an item is pressed.
Note: The callback Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the tag parameter when the menu item was created.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
callback | Callable | — |
SetItemCheckablevoid
public static void SetItemCheckable(Rid rid, int idx, bool checkable);Sets whether the item at index idx has a checkbox. If false, sets the type of the item to plain text.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
checkable | bool | — |
SetItemCheckedvoid
public static void SetItemChecked(Rid rid, int idx, bool @checked);Sets the checkstate status of the item at index idx.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
checked | bool | — |
SetItemDisabledvoid
public static void SetItemDisabled(Rid rid, int idx, bool disabled);Enables/disables the item at index idx. When it is disabled, it can't be selected and its action can't be invoked.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
disabled | bool | — |
public static void SetItemHidden(Rid rid, int idx, bool hidden);Hides/shows the item at index idx. When it is hidden, an item does not appear in a menu and its action cannot be invoked.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
hidden | bool | — |
SetItemHoverCallbacksvoid
public static void SetItemHoverCallbacks(Rid rid, int idx, Callable callback);Sets the callback of the item at index idx. The callback is emitted when an item is hovered.
Note: The callback Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the tag parameter when the menu item was created.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
callback | Callable | — |
SetItemIconvoid
public static void SetItemIcon(Rid rid, int idx, Texture2D icon);Replaces the Texture2D icon of the specified idx.
Note: This method is implemented on macOS and Windows.
Note: This method is not supported by macOS Dock menu items.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
icon | Texture2D | — |
SetItemIndentationLevelvoid
public static void SetItemIndentationLevel(Rid rid, int idx, int level);Sets the horizontal offset of the item at the given idx.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
level | int | — |
SetItemIndeterminatevoid
public static void SetItemIndeterminate(Rid rid, int idx, bool indeterminate);Sets the indeterminate status of the item at index idx.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
indeterminate | bool | — |
SetItemIndexint
public static int SetItemIndex(Rid rid, int idx, int targetIdx);Changes the index of the item at index idx to be at index target_idx. This can be used to move an item above other items.
Returns the new index of the moved item, it's not guaranteed to be the same as target_idx.
Note: The indices of any items between index idx and index target_idx will be shifted by one.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
targetIdx | int | — |
intSetItemKeyCallbackvoid
public static void SetItemKeyCallback(Rid rid, int idx, Callable keyCallback);Sets the callback of the item at index idx. Callback is emitted when its accelerator is activated.
Note: The key_callback Callable needs to accept exactly one Variant parameter, the parameter passed to the Callable will be the value passed to the tag parameter when the menu item was created.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
keyCallback | Callable | — |
SetItemMaxStatesvoid
public static void SetItemMaxStates(Rid rid, int idx, int maxStates);Sets number of state of a multistate item. See NativeMenu.AddMultistateItem for details.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
maxStates | int | — |
SetItemRadioCheckablevoid
public static void SetItemRadioCheckable(Rid rid, int idx, bool checkable);Sets the type of the item at the specified index idx to radio button. If false, sets the type of the item to plain text.
Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
checkable | bool | — |
SetItemStatevoid
public static void SetItemState(Rid rid, int idx, int state);Sets the state of a multistate item. See NativeMenu.AddMultistateItem for details.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
state | int | — |
SetItemSubmenuvoid
public static void SetItemSubmenu(Rid rid, int idx, Rid submenuRid);Sets the submenu RID of the item at index idx. The submenu is a global menu that would be shown when the item is clicked.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
submenuRid | Rid | — |
SetItemTagvoid
public static void SetItemTag(Rid rid, int idx, Variant tag);Sets the metadata of an item, which may be of any type. You can later get it with NativeMenu.GetItemTag, which provides a simple way of assigning context data to items.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
tag | Variant | — |
SetItemTextvoid
public static void SetItemText(Rid rid, int idx, string text);Sets the text of the item at index idx.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
text | string | — |
SetItemTooltipvoid
public static void SetItemTooltip(Rid rid, int idx, string tooltip);Sets the string tooltip of the item at the specified index idx.
Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
idx | int | — |
tooltip | string | — |
SetMinimumWidthvoid
public static void SetMinimumWidth(Rid rid, float width);Sets the minimum width of the global menu. Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
width | float | — |
SetPopupCloseCallbackvoid
public static void SetPopupCloseCallback(Rid rid, Callable callback);Registers callable to emit when the menu is about to show.
Note: The OS can simulate menu opening to track menu item changes and global shortcuts, in which case the corresponding close callback is not triggered. Use NativeMenu.IsOpened to check if the menu is currently opened.
Note: This method is implemented on macOS and Windows.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
callback | Callable | — |
SetPopupOpenCallbackvoid
public static void SetPopupOpenCallback(Rid rid, Callable callback);Registers callable to emit after the menu is closed. Note: This method is implemented only on macOS.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
callback | Callable | — |
SetSystemMenuTextvoid
public static void SetSystemMenuText(NativeMenu.SystemMenus menuId, string name);Sets the text of the system menu item. Note: This method is implemented on macOS.
| Name | Type | Default |
|---|---|---|
menuId | NativeMenu.SystemMenus | — |
name | string | — |
NativeMenu.Feature
| Value | Description |
|---|---|
GlobalMenu = 0 |
|
HoverCallback = 3 |
|
KeyCallback = 4 |
|
OpenCloseCallback = 2 |
|
PopupMenu = 1 |
|
NativeMenu.SystemMenus
| Value | Description |
|---|---|
ApplicationMenuId = 2 | Application (first menu after "Apple" menu on macOS) menu ID. |
DockMenuId = 5 | Dock icon right-click menu ID (on macOS this menu include standard application control items and a list of open windows). |
HelpMenuId = 4 | "Help" menu ID (on macOS this menu includes help search bar). |
InvalidMenuId = 0 | Invalid special system menu ID. |
MainMenuId = 1 | Global main menu ID. |
WindowMenuId = 3 | "Window" menu ID (on macOS this menu includes standard window control items and a list of open windows). |