Table of Contents

Class MenuBar

A horizontal menu bar that creates a menu for each PopupMenu child.

Inheritance
MenuBar

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 title, or node name if title is empty. Item title can be overridden using MenuBar.set_menu_title.

Properties

Flat MenuBar don't display item decoration.

var flat : bool = false

Property Value

bool
  • void set_flat(bool value)
  • bool is_flat

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

var language : String = ""

Property Value

String

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 prefer_native_menu property of the child nodes.

var prefer_global_menu : bool = true

Property Value

bool
  • void set_prefer_global_menu(bool value)
  • bool is_prefer_global_menu

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

Property Value

int
  • void set_start_index(int value)
  • int get_start_index

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

var switch_on_hover : bool = true

Property Value

bool
  • void set_switch_on_hover(bool value)
  • bool is_switch_on_hover

Base text writing direction.

var text_direction : int = 0

Property Value

int
  • void set_text_direction(int value)
  • int get_text_direction

Theme Property

Default text Color of the menu item.

 = ``Color(0.875, 0.875, 0.875, 1)``

Property Value

Color

Theme Property

Text Color used when the menu item is disabled.

 = ``Color(0.875, 0.875, 0.875, 0.5)``

Property Value

Color

Theme Property

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(0.95, 0.95, 0.95, 1)``

Property Value

Color

Theme Property

Text Color used when the menu item is being hovered.

 = ``Color(0.95, 0.95, 0.95, 1)``

Property Value

Color

Theme Property

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

 = ``Color(1, 1, 1, 1)``

Property Value

Color

Theme Property

The tint of text outline of the menu item.

 = ``Color(0, 0, 0, 1)``

Property Value

Color

Theme Property

Text Color used when the menu item is being pressed.

 = ``Color(1, 1, 1, 1)``

Property Value

Color

Theme Property

The horizontal space between menu items.

 = ``4``

Property Value

int

Theme Property

The size of the text outline.

Note: If using a font with multichannel_signed_distance_field enabled, its 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.

 = ``0``

Property Value

int

Theme Property

Font of the menu item's text.

Font font

Property Value

Font

Theme Property

Font size of the menu item's text.

int font_size

Property Value

int

Theme Property

StyleBox used when the menu item is disabled.

StyleBox disabled

Property Value

StyleBox

Theme Property

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

StyleBox disabled_mirrored

Property Value

StyleBox

Theme Property

StyleBox used when the menu item is being hovered.

StyleBox hover

Property Value

StyleBox

Theme Property

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

StyleBox hover_mirrored

Property Value

StyleBox

Theme Property

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

StyleBox hover_pressed

Property Value

StyleBox

Theme Property

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

StyleBox hover_pressed_mirrored

Property Value

StyleBox

Theme Property

Default StyleBox for the menu item.

StyleBox normal

Property Value

StyleBox

Theme Property

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

StyleBox normal_mirrored

Property Value

StyleBox

Theme Property

StyleBox used when the menu item is being pressed.

StyleBox pressed

Property Value

StyleBox

Theme Property

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

StyleBox pressed_mirrored

Property Value

StyleBox

Methods

Qualifiers: const

Returns number of menu items.

int get_menu_count

Qualifiers: const

Returns PopupMenu associated with menu item.

PopupMenu get_menu_popup(int menu)

Parameters

menu int

Qualifiers: const

Returns menu item title.

String get_menu_title(int menu)

Parameters

menu int

Qualifiers: const

Returns menu item tooltip.

String get_menu_tooltip(int menu)

Parameters

menu int

Qualifiers: const

Returns true, if menu item is disabled.

bool is_menu_disabled(int menu)

Parameters

menu int

Qualifiers: const

Returns true, if menu item is hidden.

bool is_menu_hidden(int menu)

Parameters

menu int

Qualifiers: const

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

bool is_native_menu

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

void set_disable_shortcuts(bool disabled)

Parameters

disabled bool

If true, menu item is disabled.

void set_menu_disabled(int menu, bool disabled)

Parameters

menu int
disabled bool

If true, menu item is hidden.

void set_menu_hidden(int menu, bool hidden)

Parameters

menu int
hidden bool

Sets menu item title.

void set_menu_title(int menu, String title)

Parameters

menu int
title String

Sets menu item tooltip.

void set_menu_tooltip(int menu, String tooltip)

Parameters

menu int
tooltip String