Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
MenuBar¶
继承: Control < CanvasItem < Node < Object
水平菜单栏,会为每个 PopupMenu 子项创建一个 MenuButton。
描述¶
水平菜单栏,会为每个 PopupMenu 子项创建一个 MenuButton。向这个节点添加 PopupMenu 就会创建新的项目。
属性¶
|
||
|
||
|
||
|
||
|
||
|
方法¶
get_menu_count ( ) const |
|
get_menu_popup ( int menu ) const |
|
get_menu_title ( int menu ) const |
|
get_menu_tooltip ( int menu ) const |
|
is_menu_disabled ( int menu ) const |
|
is_menu_hidden ( int menu ) const |
|
is_native_menu ( ) const |
|
void |
set_disable_shortcuts ( bool disabled ) |
void |
set_menu_disabled ( int menu, bool disabled ) |
void |
set_menu_hidden ( int menu, bool hidden ) |
void |
set_menu_title ( int menu, String title ) |
void |
set_menu_tooltip ( int menu, String tooltip ) |
主题属性¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
属性说明¶
bool flat = false
扁平的 MenuBar,不显示项目装饰。
String language = ""
语言代码,用于断行和文本塑形算法,如果留空则使用当前区域设置。
bool prefer_global_menu = true
如果为 true
,则 MenuBar 会在支持系统全局菜单时使用系统全局菜单。
int start_index = -1
在全局菜单中插入第一个 MenuBar 项目的位置。
bool switch_on_hover = true
如果为 true
,当光标悬停在菜单项上方时,将关闭当前的 PopupMenu 并打开另一个。
TextDirection text_direction = 0
void set_text_direction ( TextDirection value )
TextDirection get_text_direction ( )
基础文本书写方向。
方法说明¶
int get_menu_count ( ) const
返回菜单项的数量。
PopupMenu get_menu_popup ( int menu ) const
返回与菜单项关联的 PopupMenu。
String get_menu_title ( int menu ) const
返回菜单项的标题。
String get_menu_tooltip ( int menu ) const
返回菜单项的工具提示。
bool is_menu_disabled ( int menu ) const
如果菜单项为禁用状态,则返回 true
。
bool is_menu_hidden ( int menu ) const
如果菜单项为隐藏状态,则返回 true
。
bool is_native_menu ( ) const
如果支持系统全局菜单,而且该 MenuBar 使用全局菜单,则返回 true
。
void set_disable_shortcuts ( bool disabled )
如果为 true
,快捷方式将被禁用,无法用于触发按钮。
void set_menu_disabled ( int menu, bool disabled )
为 true
时,菜单项为禁用状态。
void set_menu_hidden ( int menu, bool hidden )
为 true
时,菜单项为隐藏状态。
void set_menu_title ( int menu, String title )
设置菜单项的标题。
void set_menu_tooltip ( int menu, String tooltip )
设置菜单项的工具提示。
主题属性说明¶
Color font_color = Color(0.875, 0.875, 0.875, 1)
菜单项的默认文字 Color。
Color font_disabled_color = Color(0.875, 0.875, 0.875, 0.5)
菜单项处于禁用状态时使用的文字 Color。
Color font_focus_color = Color(0.95, 0.95, 0.95, 1)
菜单项处于聚焦状态时使用的文字 Color。只替换按钮的正常文本颜色。禁用、悬停和按下状态优先于这个颜色。
Color font_hover_color = Color(0.95, 0.95, 0.95, 1)
菜单项处于悬停状态时使用的文字 Color。
Color font_hover_pressed_color = Color(1, 1, 1, 1)
菜单项处于悬停且按下状态时使用的文字 Color。
Color font_outline_color = Color(1, 1, 1, 1)
菜单项文本轮廓的色调。
Color font_pressed_color = Color(1, 1, 1, 1)
菜单项处于按下状态时使用的文字 Color。
int h_separation = 4
菜单项之间的水平距离。
int outline_size = 0
文字轮廓的大小。
注意:如果使用启用了 FontFile.multichannel_signed_distance_field 的字体,其 FontFile.msdf_pixel_range 必须至少设置为 outline_size 的两倍,轮廓渲染才能看起来正确。否则,轮廓可能会比预期的更早被切断。
Font font
菜单项文本的字体 Font。
int font_size
菜单项文本的字体大小。
StyleBox disabled
菜单项处于禁用状态时使用的 StyleBox。
StyleBox disabled_mirrored
菜单项处于禁用状态时使用的 StyleBox(用于从右至左布局)。
StyleBox hover
菜单项处于悬停状态时使用的 StyleBox。
StyleBox hover_mirrored
菜单项处于悬停状态时使用的 StyleBox(用于从右至左布局)。
StyleBox hover_pressed
菜单项处于按下并悬停状态时使用的 StyleBox。
StyleBox hover_pressed_mirrored
菜单项处于按下并悬停状态时使用的 StyleBox(用于从右至左布局)。
StyleBox normal
菜单项的默认 StyleBox。
StyleBox normal_mirrored
菜单项的默认 StyleBox(用于从右至左布局)。
StyleBox pressed
菜单项处于按下状态时使用的 StyleBox。
StyleBox pressed_mirrored
菜单项处于按下状态时使用的 StyleBox(用于从右至左布局)。