Class reference
MenuBar
Inherits Control
A horizontal menu bar that creates a menu for each PopupMenu child.
Description
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
bool flat = false
bool flat = falseFlat MenuBar don't display item decoration.
int focus_mode = 3
int focus_mode = 3String language = ""
String language = ""Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
bool prefer_global_menu = true
bool prefer_global_menu = trueIf 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.
int start_index = -1
int start_index = -1Position 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.
bool switch_on_hover = true
bool switch_on_hover = trueIf true, when the cursor hovers above menu item, it will close the current PopupMenu and open the other one.
int text_direction = 0
int text_direction = 0Base text writing direction.
Methods
int get_menu_count() const
int get_menu_count() constReturns number of menu items.
PopupMenu get_menu_popup(int menu) const
PopupMenu get_menu_popup(int menu) constReturns PopupMenu associated with menu item.
String get_menu_title(int menu) const
String get_menu_title(int menu) constReturns menu item title.
String get_menu_tooltip(int menu) const
String get_menu_tooltip(int menu) constReturns menu item tooltip.
bool is_menu_disabled(int menu) const
bool is_menu_disabled(int menu) constReturns true, if menu item is disabled.
bool is_menu_hidden(int menu) const
bool is_menu_hidden(int menu) constReturns true, if menu item is hidden.
bool is_native_menu() const
bool is_native_menu() constReturns true, if system global menu is supported and used by this MenuBar.
void set_disable_shortcuts(bool disabled)
bool disabled)If true, shortcuts are disabled and cannot be used to trigger the button.
void set_menu_disabled(int menu, bool disabled)
int menu, bool disabled)If true, menu item is disabled.
void set_menu_hidden(int menu, bool hidden)
int menu, bool hidden)If true, menu item is hidden.
void set_menu_title(int menu, String title)
int menu, String title)Sets menu item title.
void set_menu_tooltip(int menu, String tooltip)
int menu, String tooltip)Sets menu item tooltip.
Theme properties
Color font_color = Color(0.875, 0.875, 0.875, 1)
Color font_color = Color(0.875, 0.875, 0.875, 1)Default text Color of the menu item.
Color font_disabled_color = Color(0.875, 0.875, 0.875, 0.5)
Color font_disabled_color = Color(0.875, 0.875, 0.875, 0.5)Text Color used when the menu item is disabled.
Color font_focus_color = Color(0.95, 0.95, 0.95, 1)
Color font_focus_color = Color(0.95, 0.95, 0.95, 1)Text Color used when the menu item is focused. Only replaces the normal text color of the menu item. Disabled, hovered, and pressed states take precedence over this color.
Color font_hover_color = Color(0.95, 0.95, 0.95, 1)
Color font_hover_color = Color(0.95, 0.95, 0.95, 1)Text Color used when the menu item is being hovered.
Color font_hover_pressed_color = Color(1, 1, 1, 1)
Color font_hover_pressed_color = Color(1, 1, 1, 1)Text Color used when the menu item is being hovered and pressed.
Color font_outline_color = Color(0, 0, 0, 1)
Color font_outline_color = Color(0, 0, 0, 1)The tint of text outline of the menu item.
Color font_pressed_color = Color(1, 1, 1, 1)
Color font_pressed_color = Color(1, 1, 1, 1)Text Color used when the menu item is being pressed.
int h_separation = 4
int h_separation = 4The horizontal space between menu items.
int outline_size = 0
int outline_size = 0The size of the text outline. Note: If using a font with FontFile.multichannel_signed_distance_field enabled, its FontFile.msdf_pixel_range must be set to at least twice the value of outline_size for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
Font font
Font fontFont of the menu item's text.
int font_size
int font_sizeFont size of the menu item's text.
StyleBox disabled
StyleBox disabledStyleBox used when the menu item is disabled.
StyleBox disabled_mirrored
StyleBox disabled_mirroredStyleBox used when the menu item is disabled (for right-to-left layouts).
StyleBox hover
StyleBox hoverStyleBox used when the menu item is being hovered.
StyleBox hover_mirrored
StyleBox hover_mirroredStyleBox used when the menu item is being hovered (for right-to-left layouts).
StyleBox hover_pressed
StyleBox hover_pressedStyleBox used when the menu item is being pressed and hovered at the same time.
StyleBox hover_pressed_mirrored
StyleBox hover_pressed_mirroredStyleBox used when the menu item is being pressed and hovered at the same time (for right-to-left layouts).
StyleBox normal
StyleBox normalDefault StyleBox for the menu item.
StyleBox normal_mirrored
StyleBox normal_mirroredDefault StyleBox for the menu item (for right-to-left layouts).
StyleBox pressed
StyleBox pressedStyleBox used when the menu item is being pressed.
StyleBox pressed_mirrored
StyleBox pressed_mirroredStyleBox used when the menu item is being pressed (for right-to-left layouts).