Inheritance #

MenuBar
Table of contents

MenuBar #

is_instantiable, Node, core, not_builtin_classes

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.

Members #

var flat: bool = false#

Flat MenuBar don't display item decoration.

var language: String = ""#

Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

var prefer_global_menu: bool = 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.

var start_index: int = -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.

var switch_on_hover: bool = true#

If true, when the cursor hovers above menu item, it will close the current PopupMenu and open the other one.

var text_direction = TEXT_DIRECTION_AUTO#

Base text writing direction.

Methods #

const func get_menu_count() -> int#

Returns number of menu items.

const func get_menu_popup(menu: int) -> PopupMenu#

Returns PopupMenu associated with menu item.

const func get_menu_title(menu: int) -> String#

Returns menu item title.

const func get_menu_tooltip(menu: int) -> String#

Returns menu item tooltip.

const func is_menu_disabled(menu: int) -> bool#

Returns true, if menu item is disabled.

const func is_menu_hidden(menu: int) -> bool#

Returns true, if menu item is hidden.

const func is_native_menu() -> bool#

Returns true, if system global menu is supported and used by this MenuBar.

func set_disable_shortcuts(disabled: bool) -> void#

If true, shortcuts are disabled and cannot be used to trigger the button.

func set_menu_disabled(disabled: bool) -> void#

If true, menu item is disabled.

func set_menu_hidden(hidden: bool) -> void#

If true, menu item is hidden.

func set_menu_title(title: String) -> void#

Sets menu item title.

func set_menu_tooltip(tooltip: String) -> void#

Sets menu item tooltip.

Annotations #

Constants #

Constructors #

Enums #

Operators #

Signals #

Theme Items #

self["theme_override_colors/font_color"] = Color(0.875, 0.875, 0.875, 1) as Color#

Default text Color of the menu item.

self["theme_override_colors/font_disabled_color"] = Color(0.875, 0.875, 0.875, 0.5) as Color#

Text Color used when the menu item is disabled.

self["theme_override_colors/font_focus_color"] = Color(0.95, 0.95, 0.95, 1) as Color#

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.

self["theme_override_colors/font_hover_color"] = Color(0.95, 0.95, 0.95, 1) as Color#

Text Color used when the menu item is being hovered.

self["theme_override_colors/font_hover_pressed_color"] = Color(1, 1, 1, 1) as Color#

Text Color used when the menu item is being hovered and pressed.

self["theme_override_colors/font_outline_color"] = Color(0, 0, 0, 1) as Color#

The tint of text outline of the menu item.

self["theme_override_colors/font_pressed_color"] = Color(1, 1, 1, 1) as Color#

Text Color used when the menu item is being pressed.

self["theme_override_constants/h_separation"] = 4 as int#

The horizontal space between menu items.

self["theme_override_constants/outline_size"] = 0 as int#

The 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.

self["theme_override_fonts/font"] = font as Font#

Font of the menu item's text.

self["theme_override_font_sizes/font_size"] = font_size as int#

Font size of the menu item's text.

self["theme_override_styles/disabled"] = style as StyleBox#

StyleBox used when the menu item is disabled.

self["theme_override_styles/disabled_mirrored"] = style as StyleBox#

StyleBox used when the menu item is disabled (for right-to-left layouts).

self["theme_override_styles/hover"] = style as StyleBox#

StyleBox used when the menu item is being hovered.

self["theme_override_styles/hover_mirrored"] = style as StyleBox#

StyleBox used when the menu item is being hovered (for right-to-left layouts).

self["theme_override_styles/hover_pressed"] = style as StyleBox#

StyleBox used when the menu item is being pressed and hovered at the same time.

self["theme_override_styles/hover_pressed_mirrored"] = style as StyleBox#

StyleBox used when the menu item is being pressed and hovered at the same time (for right-to-left layouts).

self["theme_override_styles/normal"] = style as StyleBox#

Default StyleBox for the menu item.

self["theme_override_styles/normal_mirrored"] = style as StyleBox#

Default StyleBox for the menu item (for right-to-left layouts).

self["theme_override_styles/pressed"] = style as StyleBox#

StyleBox used when the menu item is being pressed.

self["theme_override_styles/pressed_mirrored"] = style as StyleBox#

StyleBox used when the menu item is being pressed (for right-to-left layouts).

Tutorials #