:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/MenuBar.xml. .. _class_MenuBar: MenuBar ======= **Inherits:** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` A horizontal menu bar that creates a menu for each :ref:`PopupMenu` child. .. rst-class:: classref-introduction-group Description ----------- A horizontal menu bar that creates a menu for each :ref:`PopupMenu` child. New items are created by adding :ref:`PopupMenu`\ s to this node. Item title is determined by :ref:`Window.title`, or node name if :ref:`Window.title` is empty. Item title can be overridden using :ref:`set_menu_title()`. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`flat` | ``false`` | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`FocusMode` | focus_mode | ``3`` (overrides :ref:`Control`) | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`String` | :ref:`language` | ``""`` | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`prefer_global_menu` | ``true`` | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`int` | :ref:`start_index` | ``-1`` | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`switch_on_hover` | ``true`` | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`TextDirection` | :ref:`text_direction` | ``0`` | +--------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_menu_count`\ (\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PopupMenu` | :ref:`get_menu_popup`\ (\ menu\: :ref:`int`\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_menu_title`\ (\ menu\: :ref:`int`\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_menu_tooltip`\ (\ menu\: :ref:`int`\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_menu_disabled`\ (\ menu\: :ref:`int`\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_menu_hidden`\ (\ menu\: :ref:`int`\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_native_menu`\ (\ ) |const| | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_disable_shortcuts`\ (\ disabled\: :ref:`bool`\ ) | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_menu_disabled`\ (\ menu\: :ref:`int`, disabled\: :ref:`bool`\ ) | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_menu_hidden`\ (\ menu\: :ref:`int`, hidden\: :ref:`bool`\ ) | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_menu_title`\ (\ menu\: :ref:`int`, title\: :ref:`String`\ ) | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_menu_tooltip`\ (\ menu\: :ref:`int`, tooltip\: :ref:`String`\ ) | +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-reftable-group Theme Properties ---------------- .. table:: :widths: auto +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_color` | ``Color(0.875, 0.875, 0.875, 1)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_disabled_color` | ``Color(0.875, 0.875, 0.875, 0.5)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_focus_color` | ``Color(0.95, 0.95, 0.95, 1)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_hover_color` | ``Color(0.95, 0.95, 0.95, 1)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_hover_pressed_color` | ``Color(1, 1, 1, 1)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_outline_color` | ``Color(0, 0, 0, 1)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Color` | :ref:`font_pressed_color` | ``Color(1, 1, 1, 1)`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`int` | :ref:`h_separation` | ``4`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`int` | :ref:`outline_size` | ``0`` | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Font` | :ref:`font` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`int` | :ref:`font_size` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`disabled` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`disabled_mirrored` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`hover` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`hover_mirrored` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`hover_pressed` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`hover_pressed_mirrored` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`normal` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`normal_mirrored` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`pressed` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ | :ref:`StyleBox` | :ref:`pressed_mirrored` | | +---------------------------------+-------------------------------------------------------------------------------------+-------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_MenuBar_property_flat: .. rst-class:: classref-property :ref:`bool` **flat** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_flat**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_flat**\ (\ ) Flat **MenuBar** don't display item decoration. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_property_language: .. rst-class:: classref-property :ref:`String` **language** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_language**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_language**\ (\ ) Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_property_prefer_global_menu: .. rst-class:: classref-property :ref:`bool` **prefer_global_menu** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_prefer_global_menu**\ (\ value\: :ref:`bool`\ ) - :ref:`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 :ref:`PopupMenu`\ s are inaccessible. \ **Note:** This property overrides the value of the :ref:`PopupMenu.prefer_native_menu` property of the child nodes. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_property_start_index: .. rst-class:: classref-property :ref:`int` **start_index** = ``-1`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_start_index**\ (\ value\: :ref:`int`\ ) - :ref:`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 :ref:`start_index` are inserted first. Menus with :ref:`start_index` equal to ``-1`` are inserted last. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_property_switch_on_hover: .. rst-class:: classref-property :ref:`bool` **switch_on_hover** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_switch_on_hover**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_switch_on_hover**\ (\ ) If ``true``, when the cursor hovers above menu item, it will close the current :ref:`PopupMenu` and open the other one. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_property_text_direction: .. rst-class:: classref-property :ref:`TextDirection` **text_direction** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_text_direction**\ (\ value\: :ref:`TextDirection`\ ) - :ref:`TextDirection` **get_text_direction**\ (\ ) Base text writing direction. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_MenuBar_method_get_menu_count: .. rst-class:: classref-method :ref:`int` **get_menu_count**\ (\ ) |const| :ref:`🔗` Returns number of menu items. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_get_menu_popup: .. rst-class:: classref-method :ref:`PopupMenu` **get_menu_popup**\ (\ menu\: :ref:`int`\ ) |const| :ref:`🔗` Returns :ref:`PopupMenu` associated with menu item. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_get_menu_title: .. rst-class:: classref-method :ref:`String` **get_menu_title**\ (\ menu\: :ref:`int`\ ) |const| :ref:`🔗` Returns menu item title. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_get_menu_tooltip: .. rst-class:: classref-method :ref:`String` **get_menu_tooltip**\ (\ menu\: :ref:`int`\ ) |const| :ref:`🔗` Returns menu item tooltip. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_is_menu_disabled: .. rst-class:: classref-method :ref:`bool` **is_menu_disabled**\ (\ menu\: :ref:`int`\ ) |const| :ref:`🔗` Returns ``true``, if menu item is disabled. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_is_menu_hidden: .. rst-class:: classref-method :ref:`bool` **is_menu_hidden**\ (\ menu\: :ref:`int`\ ) |const| :ref:`🔗` Returns ``true``, if menu item is hidden. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_is_native_menu: .. rst-class:: classref-method :ref:`bool` **is_native_menu**\ (\ ) |const| :ref:`🔗` Returns ``true``, if system global menu is supported and used by this **MenuBar**. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_set_disable_shortcuts: .. rst-class:: classref-method |void| **set_disable_shortcuts**\ (\ disabled\: :ref:`bool`\ ) :ref:`🔗` If ``true``, shortcuts are disabled and cannot be used to trigger the button. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_set_menu_disabled: .. rst-class:: classref-method |void| **set_menu_disabled**\ (\ menu\: :ref:`int`, disabled\: :ref:`bool`\ ) :ref:`🔗` If ``true``, menu item is disabled. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_set_menu_hidden: .. rst-class:: classref-method |void| **set_menu_hidden**\ (\ menu\: :ref:`int`, hidden\: :ref:`bool`\ ) :ref:`🔗` If ``true``, menu item is hidden. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_set_menu_title: .. rst-class:: classref-method |void| **set_menu_title**\ (\ menu\: :ref:`int`, title\: :ref:`String`\ ) :ref:`🔗` Sets menu item title. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_method_set_menu_tooltip: .. rst-class:: classref-method |void| **set_menu_tooltip**\ (\ menu\: :ref:`int`, tooltip\: :ref:`String`\ ) :ref:`🔗` Sets menu item tooltip. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Theme Property Descriptions --------------------------- .. _class_MenuBar_theme_color_font_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_color** = ``Color(0.875, 0.875, 0.875, 1)`` :ref:`🔗` Default text :ref:`Color` of the menu item. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_color_font_disabled_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_disabled_color** = ``Color(0.875, 0.875, 0.875, 0.5)`` :ref:`🔗` Text :ref:`Color` used when the menu item is disabled. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_color_font_focus_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_focus_color** = ``Color(0.95, 0.95, 0.95, 1)`` :ref:`🔗` Text :ref:`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. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_color_font_hover_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_hover_color** = ``Color(0.95, 0.95, 0.95, 1)`` :ref:`🔗` Text :ref:`Color` used when the menu item is being hovered. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_color_font_hover_pressed_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_hover_pressed_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗` Text :ref:`Color` used when the menu item is being hovered and pressed. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_color_font_outline_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_outline_color** = ``Color(0, 0, 0, 1)`` :ref:`🔗` The tint of text outline of the menu item. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_color_font_pressed_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_pressed_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗` Text :ref:`Color` used when the menu item is being pressed. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_constant_h_separation: .. rst-class:: classref-themeproperty :ref:`int` **h_separation** = ``4`` :ref:`🔗` The horizontal space between menu items. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_constant_outline_size: .. rst-class:: classref-themeproperty :ref:`int` **outline_size** = ``0`` :ref:`🔗` The size of the text outline. \ **Note:** If using a font with :ref:`FontFile.multichannel_signed_distance_field` enabled, its :ref:`FontFile.msdf_pixel_range` must be set to at least *twice* the value of :ref:`outline_size` for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_font_font: .. rst-class:: classref-themeproperty :ref:`Font` **font** :ref:`🔗` :ref:`Font` of the menu item's text. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_font_size_font_size: .. rst-class:: classref-themeproperty :ref:`int` **font_size** :ref:`🔗` Font size of the menu item's text. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_disabled: .. rst-class:: classref-themeproperty :ref:`StyleBox` **disabled** :ref:`🔗` :ref:`StyleBox` used when the menu item is disabled. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_disabled_mirrored: .. rst-class:: classref-themeproperty :ref:`StyleBox` **disabled_mirrored** :ref:`🔗` :ref:`StyleBox` used when the menu item is disabled (for right-to-left layouts). .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_hover: .. rst-class:: classref-themeproperty :ref:`StyleBox` **hover** :ref:`🔗` :ref:`StyleBox` used when the menu item is being hovered. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_hover_mirrored: .. rst-class:: classref-themeproperty :ref:`StyleBox` **hover_mirrored** :ref:`🔗` :ref:`StyleBox` used when the menu item is being hovered (for right-to-left layouts). .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_hover_pressed: .. rst-class:: classref-themeproperty :ref:`StyleBox` **hover_pressed** :ref:`🔗` :ref:`StyleBox` used when the menu item is being pressed and hovered at the same time. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_hover_pressed_mirrored: .. rst-class:: classref-themeproperty :ref:`StyleBox` **hover_pressed_mirrored** :ref:`🔗` :ref:`StyleBox` used when the menu item is being pressed and hovered at the same time (for right-to-left layouts). .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_normal: .. rst-class:: classref-themeproperty :ref:`StyleBox` **normal** :ref:`🔗` Default :ref:`StyleBox` for the menu item. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_normal_mirrored: .. rst-class:: classref-themeproperty :ref:`StyleBox` **normal_mirrored** :ref:`🔗` Default :ref:`StyleBox` for the menu item (for right-to-left layouts). .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_pressed: .. rst-class:: classref-themeproperty :ref:`StyleBox` **pressed** :ref:`🔗` :ref:`StyleBox` used when the menu item is being pressed. .. rst-class:: classref-item-separator ---- .. _class_MenuBar_theme_style_pressed_mirrored: .. rst-class:: classref-themeproperty :ref:`StyleBox` **pressed_mirrored** :ref:`🔗` :ref:`StyleBox` used when the menu item is being pressed (for right-to-left layouts). .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`