MenuBar
Inherits: Control < CanvasItem < Actor < Object
A horizontal menu bar that creates a menu for each PopupMenu child.
Description
Section titled “Description”A horizontal menu bar that creates a menu for each PopupMenu child. New items are created by adding PopupMenus to this actor. Item title is determined by Window.title, or actor name if Window.title is empty. Item title can be overridden using set_menu_title().
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| bool | flat | false |
| Control.FocusMode | focus_mode | 3 |
| String | language | "" |
| bool | prefer_global_menu | true |
| int | start_index | -1 |
| bool | switch_on_hover | true |
| Control.TextDirection | text_direction | 0 |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| int | get_menu_count() |
| PopupMenu | get_menu_popup(menu) |
| String | get_menu_title(menu) |
| String | get_menu_tooltip(menu) |
| bool | is_menu_disabled(menu) |
| bool | is_menu_hidden(menu) |
| bool | is_native_menu() |
| void | set_disable_shortcuts(disabled) |
| void | set_menu_disabled(menu, disabled) |
| void | set_menu_hidden(menu, hidden) |
| void | set_menu_title(menu, title) |
| void | set_menu_tooltip(menu, tooltip) |
Property descriptions
Section titled “Property descriptions”bool flat = false
Setter/getter: set_flat(), is_flat()
Flat MenuBar don’t display item decoration.
focus_mode
Section titled “focus_mode”Control.FocusMode focus_mode = 3
Setter/getter: set_focus_mode(), get_focus_mode()
No description yet.
language
Section titled “language”String language = ""
Setter/getter: set_language(), get_language()
Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.
prefer_global_menu
Section titled “prefer_global_menu”bool prefer_global_menu = true
Setter/getter: set_prefer_global_menu(), is_prefer_global_menu()
If true, MenuBar will use system global menu when supported.
Note: If true and global menu is supported, this actor is not displayed, has zero size, and all its child actors except PopupMenus are inaccessible.
Note: This property overrides the value of the PopupMenu.prefer_native_menu property of the child actors.
start_index
Section titled “start_index”int start_index = -1
Setter/getter: set_start_index(), get_start_index()
Position order in the global menu to insert MenuBar items at. All menu items in the MenuBar are always inserted as a continuous range. Menus with lower start_index are inserted first. Menus with start_index equal to -1 are inserted last.
switch_on_hover
Section titled “switch_on_hover”bool switch_on_hover = true
Setter/getter: set_switch_on_hover(), is_switch_on_hover()
If true, when the cursor hovers above menu item, it will close the current PopupMenu and open the other one.
text_direction
Section titled “text_direction”Control.TextDirection text_direction = 0
Setter/getter: set_text_direction(), get_text_direction()
Base text writing direction.
Method descriptions
Section titled “Method descriptions”get_menu_count
Section titled “get_menu_count”int get_menu_count() const
Returns number of menu items.
get_menu_popup
Section titled “get_menu_popup”PopupMenu get_menu_popup(menu: int) const
Returns PopupMenu associated with menu item.
get_menu_title
Section titled “get_menu_title”String get_menu_title(menu: int) const
Returns menu item title.
get_menu_tooltip
Section titled “get_menu_tooltip”String get_menu_tooltip(menu: int) const
Returns menu item tooltip.
is_menu_disabled
Section titled “is_menu_disabled”bool is_menu_disabled(menu: int) const
Returns true if the menu item is disabled.
is_menu_hidden
Section titled “is_menu_hidden”bool is_menu_hidden(menu: int) const
Returns true if the menu item is hidden.
is_native_menu
Section titled “is_native_menu”bool is_native_menu() const
Returns true if the current system’s global menu is supported and used by this MenuBar.
set_disable_shortcuts
Section titled “set_disable_shortcuts”void set_disable_shortcuts(disabled: bool)
If true, shortcuts are disabled and cannot be used to trigger the button.
set_menu_disabled
Section titled “set_menu_disabled”void set_menu_disabled(menu: int, disabled: bool)
If true, menu item is disabled.
set_menu_hidden
Section titled “set_menu_hidden”void set_menu_hidden(menu: int, hidden: bool)
If true, menu item is hidden.
set_menu_title
Section titled “set_menu_title”void set_menu_title(menu: int, title: String)
Sets menu item title.
set_menu_tooltip
Section titled “set_menu_tooltip”void set_menu_tooltip(menu: int, tooltip: String)
Sets menu item tooltip.