MenuButton
Button opening a command menu without a persistent selected item.
MenuButton opens its owned PopupMenu. Obtain it through GetPopup, populate commands and connect the menu’s IdPressed to run a command by ID. The button’s Pressed means opening/closing activation rather than command selection. Use OptionButton for persistent selection.
The constructor sets Flat = true, ToggleMode = true, ActionMode = Press and FocusMode = Accessibility. Set FocusMode = All for ordinary Tab navigation. Toggle state follows popup visibility rather than an application setting. ItemCount changes PopupMenu row count without supplying meaningful labels or actions.
AboutToPopup is emitted before ShowPopup displays the menu; use it to refresh command availability/content. ShowPopup requires a Viewport and directly opens the menu, bypassing Press’s Disabled check. Call it for an active element inside the tree. GetPopup returns a shared internal object — do not free or reparent it.
SwitchOnHover defaults to false. Enabling it on related MenuButtons before opening allows an already open menu to switch to another eligible button on hover. It does not open the first menu on arbitrary hover. SetDisableShortcuts disables local shortcut handling for this button/menu rather than global InputMap actions.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
MenuButtonConstructor
public MenuButton();Creates a flat toggle button with ActionMode = Press, FocusMode = Accessibility and hidden internal PopupMenu. SwitchOnHover = false.
Properties2
ItemCountProperty
public int ItemCount { get; set; }Internal PopupMenu row count. Nonnegative setter adds empty rows or truncates the tail. Populate labels, IDs and actions separately through GetPopup.
SwitchOnHoverProperty
public bool SwitchOnHover { get; set; }Allows hover switching between related already open MenuButtons, default false. Configure before opening; does not open the first menu on ordinary hover.
Methods7
GetItemCountint
public int GetItemCount();Internal PopupMenu row count. Nonnegative setter adds empty rows or truncates the tail. Populate labels, IDs and actions separately through GetPopup.
intCount of all rows including separators.
GetPopupPopupMenu
public PopupMenu GetPopup();Returns the button-owned internal PopupMenu. Populate commands and handle its IdPressed there. Do not free/reparent separately.
PopupMenuShared internal PopupMenu owned by the button.
IsSwitchOnHoverbool
public bool IsSwitchOnHover();Allows hover switching between related already open MenuButtons, default false. Configure before opening; does not open the first menu on ordinary hover.
booltrue when hover switching between open menus is configured.
SetDisableShortcutsvoid
public void SetDisableShortcuts(bool disabled);Disables local list/base-button shortcut handling. Does not change application InputMap or disable ordinary Select/list methods.
| Name | Type | Default |
|---|---|---|
disabled | bool | — |
disabledDisables local list/base-button shortcut handling. Does not change application InputMap or disable ordinary Select/list methods.
SetItemCountvoid
public void SetItemCount(int count);Internal PopupMenu row count. Nonnegative setter adds empty rows or truncates the tail. Populate labels, IDs and actions separately through GetPopup.
| Name | Type | Default |
|---|---|---|
count | int | — |
countInternal PopupMenu row count. Nonnegative setter adds empty rows or truncates the tail. Populate labels, IDs and actions separately through GetPopup.
SetSwitchOnHovervoid
public void SetSwitchOnHover(bool enable);Allows hover switching between related already open MenuButtons, default false. Configure before opening; does not open the first menu on ordinary hover.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableAllows hover switching between related already open MenuButtons, default false. Configure before opening; does not open the first menu on ordinary hover.
ShowPopupvoid
public void ShowPopup();Directly opens PopupMenu when a Viewport exists, first emitting AboutToPopup. Does not check Disabled as Press does; use for an active in-tree element.
Signals and events1
AboutToPopupEvent
public event Action AboutToPopup;Emitted before ShowPopup displays the menu. Suitable for refreshing command content/availability; does not report command selection.