MenuBar

继承: Control < CanvasItem < Node < 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 PopupMenu s to this node.

属性

方法

intget_menu_count ( ) const1
PopupMenuget_menu_popup ( menu: int ) const1
Stringget_menu_title ( menu: int ) const1
Stringget_menu_tooltip ( menu: int ) const1
boolis_menu_disabled ( menu: int ) const1
boolis_menu_hidden ( menu: int ) const1
boolis_native_menu ( ) const1
voidset_disable_shortcuts ( disabled: bool )
voidset_menu_disabled ( menu: int, disabled: bool )
voidset_menu_hidden ( menu: int, hidden: bool )
voidset_menu_title ( menu: int, title: String )
voidset_menu_tooltip ( menu: int, tooltip: String )

主题属性


属性说明

bool flat = false

  • void set_flat ( value: bool )
  • bool is_flat ( )

Flat MenuBar don't display item decoration.


String language = ""

  • void set_language ( value: String )
  • String get_language ( )

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


bool prefer_global_menu = true

  • void set_prefer_global_menu ( value: bool )
  • bool is_prefer_global_menu ( )

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 PopupMenu s are inaccessible.

Note: This property overrides the value of the PopupMenu.prefer_native_menu property of the child nodes.


int start_index = -1

  • void set_start_index ( value: int )
  • int 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

  • void set_switch_on_hover ( value: bool )
  • bool is_switch_on_hover ( )

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


TextDirection text_direction = 0

Base text writing direction.


方法说明

int get_menu_count ( ) const1

Returns number of menu items.


PopupMenu get_menu_popup ( menu: int ) const1

Returns PopupMenu associated with menu item.


String get_menu_title ( menu: int ) const1

Returns menu item title.


String get_menu_tooltip ( menu: int ) const1

Returns menu item tooltip.


bool is_menu_disabled ( menu: int ) const1

Returns true, if menu item is disabled.


bool is_menu_hidden ( menu: int ) const1

Returns true, if menu item is hidden.


bool is_native_menu ( ) const1

Returns true, if system 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.


主题属性说明

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)

Text Color used when the menu item is disabled.


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)

Text Color used when the menu item is being hovered.


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)

The tint of text outline of the menu item.


Color font_pressed_color = Color(1, 1, 1, 1)

Text Color used when the menu item is being pressed.


int h_separation = 4

The horizontal space between menu items.


int outline_size = 0

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.


Font font

Font of the menu item's text.


int font_size

Font size of the menu item's text.


StyleBox disabled

StyleBox used when the menu item is disabled.


StyleBox disabled_mirrored

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


StyleBox hover

StyleBox used when the menu item is being hovered.


StyleBox hover_mirrored

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


StyleBox hover_pressed

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


StyleBox hover_pressed_mirrored

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


StyleBox normal

Default StyleBox for the menu item.


StyleBox normal_mirrored

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


StyleBox pressed

StyleBox used when the menu item is being pressed.


StyleBox pressed_mirrored

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

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。