MenuBar
Inherits: Control < CanvasItem < Entity < Object
Description
Section titled “Description”A horizontal menu bar that creates a menu for each PopupMenu child.
A horizontal menu bar that creates a menu for each PopupMenu child. New items are created by adding PopupMenus to this node. Item title is determined by Window.title, or node 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 (overrides Control) |
| 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() const |
| PopupMenu | get_menu_popup(menu: int) const |
| String | get_menu_title(menu: int) const |
| String | get_menu_tooltip(menu: int) const |
| bool | is_menu_disabled(menu: int) const |
| bool | is_menu_hidden(menu: int) const |
| bool | is_native_menu() const |
| void | set_disable_shortcuts(disabled: bool) |
| void | set_menu_disabled(menu: int, disabled: bool) |
| void | set_menu_hidden(menu: int, hidden: bool) |
| void | set_menu_title(menu: int, title: String) |
| void | set_menu_tooltip(menu: int, tooltip: String) |
Theme items
Section titled “Theme items”font_color
Color font_color (color) = Color(0.875, 0.875, 0.875, 1)
font_disabled_color
Color font_disabled_color (color) = Color(0.875, 0.875, 0.875, 0.5)
font_focus_color
Color font_focus_color (color) = Color(0.95, 0.95, 0.95, 1)
font_hover_color
Color font_hover_color (color) = Color(0.95, 0.95, 0.95, 1)
font_hover_pressed_color
Color font_hover_pressed_color (color) = Color(1, 1, 1, 1)
font_outline_color
Color font_outline_color (color) = Color(0, 0, 0, 1)
font_pressed_color
Color font_pressed_color (color) = Color(1, 1, 1, 1)
h_separation
int h_separation (constant) = 4
outline_size
int outline_size (constant) = 0
font
Font font (font)
font_size
int font_size (font_size)
disabled
StyleBox disabled (style)
disabled_mirrored
StyleBox disabled_mirrored (style)
hover
StyleBox hover (style)
hover_mirrored
StyleBox hover_mirrored (style)
hover_pressed
StyleBox hover_pressed (style)
hover_pressed_mirrored
StyleBox hover_pressed_mirrored (style)
normal
StyleBox normal (style)
normal_mirrored
StyleBox normal_mirrored (style)
pressed
StyleBox pressed (style)
pressed_mirrored
StyleBox pressed_mirrored (style)
Property descriptions
Section titled “Property descriptions”flat
bool flat = false
Flat MenuBar don’t display item decoration.
language
String language = ""
Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.
prefer_global_menu
bool prefer_global_menu = true
If true, MenuBar will use system global menu when supported.
Note: If true and global menu is supported, this node is not displayed, has zero size, and all its child nodes except PopupMenus are inaccessible.
Note: This property overrides the value of the PopupMenu.prefer_native_menu property of the child nodes.
start_index
int start_index = -1
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
bool switch_on_hover = true
If true, when the cursor hovers above menu item, it will close the current PopupMenu and open the other one.
text_direction
Control.TextDirection text_direction = 0
Base text writing direction.
Method descriptions
Section titled “Method descriptions”get_menu_count
int get_menu_count() const
Returns number of menu items.
get_menu_popup
PopupMenu get_menu_popup(menu: int) const
Returns PopupMenu associated with menu item.
get_menu_title
String get_menu_title(menu: int) const
Returns menu item title.
get_menu_tooltip
String get_menu_tooltip(menu: int) const
Returns menu item tooltip.
is_menu_disabled
bool is_menu_disabled(menu: int) const
Returns true if the menu item is disabled.
is_menu_hidden
bool is_menu_hidden(menu: int) const
Returns true if the menu item is hidden.
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
void set_disable_shortcuts(disabled: bool)
If true, shortcuts are disabled and cannot be used to trigger the button.
set_menu_disabled
void set_menu_disabled(menu: int, disabled: bool)
If true, menu item is disabled.
set_menu_hidden
void set_menu_hidden(menu: int, hidden: bool)
If true, menu item is hidden.
set_menu_title
void set_menu_title(menu: int, title: String)
Sets menu item title.
set_menu_tooltip
void set_menu_tooltip(menu: int, tooltip: String)
Sets menu item tooltip.
