class_menubutton.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the MenuButton.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_MenuButton:
  6. MenuButton
  7. ==========
  8. **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>`
  9. Special button that brings up a :ref:`PopupMenu<class_PopupMenu>` when clicked.
  10. Description
  11. -----------
  12. Special button that brings up a :ref:`PopupMenu<class_PopupMenu>` when clicked.
  13. 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 items new properties.
  14. Properties
  15. ----------
  16. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  17. | :ref:`ActionMode<enum_BaseButton_ActionMode>` | action_mode | ``0`` *(parent override)* |
  18. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  19. | :ref:`FocusMode<enum_Control_FocusMode>` | enabled_focus_mode | ``0`` *(parent override)* |
  20. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  21. | :ref:`bool<class_bool>` | flat | ``true`` *(parent override)* |
  22. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  23. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``0`` *(parent override)* |
  24. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  25. | :ref:`bool<class_bool>` | :ref:`switch_on_hover<class_MenuButton_property_switch_on_hover>` | ``false`` |
  26. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  27. | :ref:`bool<class_bool>` | toggle_mode | ``true`` *(parent override)* |
  28. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  29. Methods
  30. -------
  31. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_popup<class_MenuButton_method_get_popup>` **(** **)** |const| |
  33. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_disable_shortcuts<class_MenuButton_method_set_disable_shortcuts>` **(** :ref:`bool<class_bool>` disabled **)** |
  35. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  36. Theme Properties
  37. ----------------
  38. +---------------------------------+---------------------+------------------------------+
  39. | :ref:`StyleBox<class_StyleBox>` | disabled | |
  40. +---------------------------------+---------------------+------------------------------+
  41. | :ref:`StyleBox<class_StyleBox>` | focus | |
  42. +---------------------------------+---------------------+------------------------------+
  43. | :ref:`Font<class_Font>` | font | |
  44. +---------------------------------+---------------------+------------------------------+
  45. | :ref:`Color<class_Color>` | font_color | Color( 0.88, 0.88, 0.88, 1 ) |
  46. +---------------------------------+---------------------+------------------------------+
  47. | :ref:`Color<class_Color>` | font_color_disabled | Color( 1, 1, 1, 0.3 ) |
  48. +---------------------------------+---------------------+------------------------------+
  49. | :ref:`Color<class_Color>` | font_color_hover | Color( 0.94, 0.94, 0.94, 1 ) |
  50. +---------------------------------+---------------------+------------------------------+
  51. | :ref:`Color<class_Color>` | font_color_pressed | Color( 1, 1, 1, 1 ) |
  52. +---------------------------------+---------------------+------------------------------+
  53. | :ref:`StyleBox<class_StyleBox>` | hover | |
  54. +---------------------------------+---------------------+------------------------------+
  55. | :ref:`int<class_int>` | hseparation | 3 |
  56. +---------------------------------+---------------------+------------------------------+
  57. | :ref:`StyleBox<class_StyleBox>` | normal | |
  58. +---------------------------------+---------------------+------------------------------+
  59. | :ref:`StyleBox<class_StyleBox>` | pressed | |
  60. +---------------------------------+---------------------+------------------------------+
  61. Signals
  62. -------
  63. .. _class_MenuButton_signal_about_to_show:
  64. - **about_to_show** **(** **)**
  65. Emitted when :ref:`PopupMenu<class_PopupMenu>` of this MenuButton is about to show.
  66. Property Descriptions
  67. ---------------------
  68. .. _class_MenuButton_property_switch_on_hover:
  69. - :ref:`bool<class_bool>` **switch_on_hover**
  70. +-----------+----------------------------+
  71. | *Default* | ``false`` |
  72. +-----------+----------------------------+
  73. | *Setter* | set_switch_on_hover(value) |
  74. +-----------+----------------------------+
  75. | *Getter* | is_switch_on_hover() |
  76. +-----------+----------------------------+
  77. 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.
  78. Method Descriptions
  79. -------------------
  80. .. _class_MenuButton_method_get_popup:
  81. - :ref:`PopupMenu<class_PopupMenu>` **get_popup** **(** **)** |const|
  82. Returns the :ref:`PopupMenu<class_PopupMenu>` contained in this button.
  83. ----
  84. .. _class_MenuButton_method_set_disable_shortcuts:
  85. - void **set_disable_shortcuts** **(** :ref:`bool<class_bool>` disabled **)**
  86. If ``true``, shortcuts are disabled and cannot be used to trigger the button.
  87. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  88. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  89. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`