MenuButton
Inherits: Button < BaseButton < Control < CanvasItem < Entity < Object
Description
Section titled “Description”A button that brings up a PopupMenu when clicked.
A button that brings up a PopupMenu when clicked. To create new items inside this PopupMenu, use get_popup().add_item("My Item Name"). You can also create them directly from Orblit editor’s inspector.
See also BaseButton which contains common properties and methods associated with this node.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| BaseButton.ActionMode | action_mode |
0 (overrides BaseButton) |
| bool | flat |
true (overrides Button) |
| Control.FocusMode | focus_mode |
3 (overrides Control) |
| int | item_count |
0 |
| int | popup/item_{index}/checkable |
0 |
| bool | popup/item_{index}/checked |
false |
| bool | popup/item_{index}/disabled |
false |
| Texture2D | popup/item_{index}/icon |
|
| int | popup/item_{index}/id |
0 |
| bool | popup/item_{index}/indeterminate |
false |
| bool | popup/item_{index}/separator |
false |
| String | popup/item_{index}/text |
"" |
| bool | switch_on_hover |
false |
| bool | toggle_mode |
true (overrides BaseButton) |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| PopupMenu | get_popup() const |
| void | set_disable_shortcuts(disabled: bool) |
| void | show_popup() |
Signals
Section titled “Signals”about_to_popup
about_to_popup()
Emitted when the PopupMenu of this MenuButton is about to show.
Property descriptions
Section titled “Property descriptions”item_count
int item_count = 0
The number of items currently in the list.
popup/item_{index}/checkable
int popup/item_{index}/checkable = 0
The checkable item type of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
popup/item_{index}/checked
bool popup/item_{index}/checked = false
If true, the item at index is checked.
Note: index is a value in the 0 .. item_count - 1 range.
Note: An item cannot be both in a checked and indeterminate state, so if checked is set to true, popup/item_{index}/indeterminate will be set to false.
popup/item_{index}/disabled
bool popup/item_{index}/disabled = false
If true, the item at index is disabled.
Note: index is a value in the 0 .. item_count - 1 range.
popup/item_{index}/icon
Texture2D popup/item_{index}/icon
The icon of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
popup/item_{index}/id
int popup/item_{index}/id = 0
The ID of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
popup/item_{index}/indeterminate
bool popup/item_{index}/indeterminate = false
If true, the item at index is in an indeterminate state.
Note: index is a value in the 0 .. item_count - 1 range.
Note: An item cannot be both in a checked and indeterminate state, so if indeterminate is set to true, popup/item_{index}/checked will be set to false.
popup/item_{index}/separator
bool popup/item_{index}/separator = false
If true, the item at index is a separator.
Note: index is a value in the 0 .. item_count - 1 range.
popup/item_{index}/text
String popup/item_{index}/text = ""
The text of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
switch_on_hover
bool switch_on_hover = false
If true, when the cursor hovers above another MenuButton within the same parent which also has switch_on_hover enabled, it will close the current MenuButton and open the other one.
Method descriptions
Section titled “Method descriptions”get_popup
PopupMenu get_popup() const
Returns the PopupMenu contained in this button.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Window.visible property.
set_disable_shortcuts
void set_disable_shortcuts(disabled: bool)
If true, shortcuts are disabled and cannot be used to trigger the button.
show_popup
void show_popup()
Adjusts popup position and sizing for the MenuButton, then shows the PopupMenu. Prefer this over using get_popup().popup().
