class_menubutton.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/MenuButton.xml.
  6. .. _class_MenuButton:
  7. MenuButton
  8. ==========
  9. **Inherits:** :ref:`Button<class_Button>` **<** :ref:`BaseButton<class_BaseButton>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Special button that brings up a :ref:`PopupMenu<class_PopupMenu>` when clicked.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Special button that brings up a :ref:`PopupMenu<class_PopupMenu>` when clicked.
  15. New items can be created inside this :ref:`PopupMenu<class_PopupMenu>` using ``get_popup().add_item("My Item Name")``. You can also create them directly from the editor. To do so, select the **MenuButton** node, then in the toolbar at the top of the 2D editor, click **Items** then click **Add** in the popup. You will be able to give each item new properties.
  16. See also :ref:`BaseButton<class_BaseButton>` which contains common properties and methods associated with this node.
  17. .. rst-class:: classref-reftable-group
  18. Properties
  19. ----------
  20. .. table::
  21. :widths: auto
  22. +-----------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------------------+
  23. | :ref:`ActionMode<enum_BaseButton_ActionMode>` | action_mode | ``0`` (overrides :ref:`BaseButton<class_BaseButton_property_action_mode>`) |
  24. +-----------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | flat | ``true`` (overrides :ref:`Button<class_Button_property_flat>`) |
  26. +-----------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------------------+
  27. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``0`` (overrides :ref:`Control<class_Control_property_focus_mode>`) |
  28. +-----------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`switch_on_hover<class_MenuButton_property_switch_on_hover>` | ``false`` |
  30. +-----------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | toggle_mode | ``true`` (overrides :ref:`BaseButton<class_BaseButton_property_toggle_mode>`) |
  32. +-----------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------------------+
  33. .. rst-class:: classref-reftable-group
  34. Methods
  35. -------
  36. .. table::
  37. :widths: auto
  38. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_popup<class_MenuButton_method_get_popup>` **(** **)** |const| |
  40. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_disable_shortcuts<class_MenuButton_method_set_disable_shortcuts>` **(** :ref:`bool<class_bool>` disabled **)** |
  42. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  43. .. rst-class:: classref-reftable-group
  44. Theme Properties
  45. ----------------
  46. .. table::
  47. :widths: auto
  48. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  49. | :ref:`Color<class_Color>` | :ref:`font_color<class_MenuButton_theme_color_font_color>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  50. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  51. | :ref:`Color<class_Color>` | :ref:`font_color_disabled<class_MenuButton_theme_color_font_color_disabled>` | ``Color( 1, 1, 1, 0.3 )`` |
  52. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  53. | :ref:`Color<class_Color>` | :ref:`font_color_focus<class_MenuButton_theme_color_font_color_focus>` | ``Color( 0.94, 0.94, 0.94, 1 )`` |
  54. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  55. | :ref:`Color<class_Color>` | :ref:`font_color_hover<class_MenuButton_theme_color_font_color_hover>` | ``Color( 0.94, 0.94, 0.94, 1 )`` |
  56. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  57. | :ref:`Color<class_Color>` | :ref:`font_color_pressed<class_MenuButton_theme_color_font_color_pressed>` | ``Color( 1, 1, 1, 1 )`` |
  58. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  59. | :ref:`int<class_int>` | :ref:`hseparation<class_MenuButton_theme_constant_hseparation>` | ``3`` |
  60. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  61. | :ref:`Font<class_Font>` | :ref:`font<class_MenuButton_theme_font_font>` | |
  62. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  63. | :ref:`StyleBox<class_StyleBox>` | :ref:`disabled<class_MenuButton_theme_style_disabled>` | |
  64. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  65. | :ref:`StyleBox<class_StyleBox>` | :ref:`focus<class_MenuButton_theme_style_focus>` | |
  66. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  67. | :ref:`StyleBox<class_StyleBox>` | :ref:`hover<class_MenuButton_theme_style_hover>` | |
  68. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  69. | :ref:`StyleBox<class_StyleBox>` | :ref:`normal<class_MenuButton_theme_style_normal>` | |
  70. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  71. | :ref:`StyleBox<class_StyleBox>` | :ref:`pressed<class_MenuButton_theme_style_pressed>` | |
  72. +---------------------------------+------------------------------------------------------------------------------+----------------------------------+
  73. .. rst-class:: classref-section-separator
  74. ----
  75. .. rst-class:: classref-descriptions-group
  76. Signals
  77. -------
  78. .. _class_MenuButton_signal_about_to_show:
  79. .. rst-class:: classref-signal
  80. **about_to_show** **(** **)**
  81. Emitted when :ref:`PopupMenu<class_PopupMenu>` of this MenuButton is about to show.
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Property Descriptions
  86. ---------------------
  87. .. _class_MenuButton_property_switch_on_hover:
  88. .. rst-class:: classref-property
  89. :ref:`bool<class_bool>` **switch_on_hover** = ``false``
  90. .. rst-class:: classref-property-setget
  91. - void **set_switch_on_hover** **(** :ref:`bool<class_bool>` value **)**
  92. - :ref:`bool<class_bool>` **is_switch_on_hover** **(** **)**
  93. If ``true``, when the cursor hovers above another **MenuButton** within the same parent which also has ``switch_on_hover`` enabled, it will close the current **MenuButton** and open the other one.
  94. .. rst-class:: classref-section-separator
  95. ----
  96. .. rst-class:: classref-descriptions-group
  97. Method Descriptions
  98. -------------------
  99. .. _class_MenuButton_method_get_popup:
  100. .. rst-class:: classref-method
  101. :ref:`PopupMenu<class_PopupMenu>` **get_popup** **(** **)** |const|
  102. Returns the :ref:`PopupMenu<class_PopupMenu>` contained in this button.
  103. \ **Warning:** This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_MenuButton_method_set_disable_shortcuts:
  107. .. rst-class:: classref-method
  108. void **set_disable_shortcuts** **(** :ref:`bool<class_bool>` disabled **)**
  109. If ``true``, shortcuts are disabled and cannot be used to trigger the button.
  110. .. rst-class:: classref-section-separator
  111. ----
  112. .. rst-class:: classref-descriptions-group
  113. Theme Property Descriptions
  114. ---------------------------
  115. .. _class_MenuButton_theme_color_font_color:
  116. .. rst-class:: classref-themeproperty
  117. :ref:`Color<class_Color>` **font_color** = ``Color( 0.88, 0.88, 0.88, 1 )``
  118. Default text :ref:`Color<class_Color>` of the **MenuButton**.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_MenuButton_theme_color_font_color_disabled:
  122. .. rst-class:: classref-themeproperty
  123. :ref:`Color<class_Color>` **font_color_disabled** = ``Color( 1, 1, 1, 0.3 )``
  124. Text :ref:`Color<class_Color>` used when the **MenuButton** is disabled.
  125. .. rst-class:: classref-item-separator
  126. ----
  127. .. _class_MenuButton_theme_color_font_color_focus:
  128. .. rst-class:: classref-themeproperty
  129. :ref:`Color<class_Color>` **font_color_focus** = ``Color( 0.94, 0.94, 0.94, 1 )``
  130. Text :ref:`Color<class_Color>` used when the **MenuButton** is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_MenuButton_theme_color_font_color_hover:
  134. .. rst-class:: classref-themeproperty
  135. :ref:`Color<class_Color>` **font_color_hover** = ``Color( 0.94, 0.94, 0.94, 1 )``
  136. Text :ref:`Color<class_Color>` used when the **MenuButton** is being hovered.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_MenuButton_theme_color_font_color_pressed:
  140. .. rst-class:: classref-themeproperty
  141. :ref:`Color<class_Color>` **font_color_pressed** = ``Color( 1, 1, 1, 1 )``
  142. Text :ref:`Color<class_Color>` used when the **MenuButton** is being pressed.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_MenuButton_theme_constant_hseparation:
  146. .. rst-class:: classref-themeproperty
  147. :ref:`int<class_int>` **hseparation** = ``3``
  148. The horizontal space between **MenuButton**'s icon and text.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_MenuButton_theme_font_font:
  152. .. rst-class:: classref-themeproperty
  153. :ref:`Font<class_Font>` **font**
  154. :ref:`Font<class_Font>` of the **MenuButton**'s text.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_MenuButton_theme_style_disabled:
  158. .. rst-class:: classref-themeproperty
  159. :ref:`StyleBox<class_StyleBox>` **disabled**
  160. :ref:`StyleBox<class_StyleBox>` used when the **MenuButton** is disabled.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_MenuButton_theme_style_focus:
  164. .. rst-class:: classref-themeproperty
  165. :ref:`StyleBox<class_StyleBox>` **focus**
  166. :ref:`StyleBox<class_StyleBox>` used when the **MenuButton** is focused. It is displayed over the current :ref:`StyleBox<class_StyleBox>`, so using :ref:`StyleBoxEmpty<class_StyleBoxEmpty>` will just disable the focus visual effect.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_MenuButton_theme_style_hover:
  170. .. rst-class:: classref-themeproperty
  171. :ref:`StyleBox<class_StyleBox>` **hover**
  172. :ref:`StyleBox<class_StyleBox>` used when the **MenuButton** is being hovered.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_MenuButton_theme_style_normal:
  176. .. rst-class:: classref-themeproperty
  177. :ref:`StyleBox<class_StyleBox>` **normal**
  178. Default :ref:`StyleBox<class_StyleBox>` for the **MenuButton**.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_MenuButton_theme_style_pressed:
  182. .. rst-class:: classref-themeproperty
  183. :ref:`StyleBox<class_StyleBox>` **pressed**
  184. :ref:`StyleBox<class_StyleBox>` used when the **MenuButton** is being pressed.
  185. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  186. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  187. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  188. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`