Skip to content
Download
API reference

MenuBar

Inherits: Control < CanvasItem < Actor < Object

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 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().

TypeNameDefault
boolflatfalse
Control.FocusModefocus_mode3
Stringlanguage""
boolprefer_global_menutrue
intstart_index-1
boolswitch_on_hovertrue
Control.TextDirectiontext_direction0
ReturnsMethod
intget_menu_count()
PopupMenuget_menu_popup(menu)
Stringget_menu_title(menu)
Stringget_menu_tooltip(menu)
boolis_menu_disabled(menu)
boolis_menu_hidden(menu)
boolis_native_menu()
voidset_disable_shortcuts(disabled)
voidset_menu_disabled(menu, disabled)
voidset_menu_hidden(menu, hidden)
voidset_menu_title(menu, title)
voidset_menu_tooltip(menu, tooltip)

bool flat = false

Setter/getter: set_flat(), is_flat()

Flat MenuBar don’t display item decoration.

Control.FocusMode focus_mode = 3

Setter/getter: set_focus_mode(), get_focus_mode()

No description yet.

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.

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.

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.

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.

Control.TextDirection text_direction = 0

Setter/getter: set_text_direction(), get_text_direction()

Base text writing direction.

int get_menu_count() const

Returns number of menu items.

PopupMenu get_menu_popup(menu: int) const

Returns PopupMenu associated with menu item.

String get_menu_title(menu: int) const

Returns menu item title.

String get_menu_tooltip(menu: int) const

Returns menu item tooltip.

bool is_menu_disabled(menu: int) const

Returns true if the menu item is disabled.

bool is_menu_hidden(menu: int) const

Returns true if the menu item is hidden.

bool is_native_menu() const

Returns true if the current system’s global menu is supported and used by this MenuBar.

void set_disable_shortcuts(disabled: bool)

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

void set_menu_disabled(menu: int, disabled: bool)

If true, menu item is disabled.

void set_menu_hidden(menu: int, hidden: bool)

If true, menu item is hidden.

void set_menu_title(menu: int, title: String)

Sets menu item title.

void set_menu_tooltip(menu: int, tooltip: String)

Sets menu item tooltip.