class_menubutton.rst 7.2 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 item new properties.
  14. See also :ref:`BaseButton<class_BaseButton>` which contains common properties and methods associated with this node.
  15. Properties
  16. ----------
  17. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  18. | :ref:`ActionMode<enum_BaseButton_ActionMode>` | action_mode | ``0`` *(parent override)* |
  19. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  20. | :ref:`bool<class_bool>` | flat | ``true`` *(parent override)* |
  21. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  22. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``0`` *(parent override)* |
  23. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`switch_on_hover<class_MenuButton_property_switch_on_hover>` | ``false`` |
  25. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  26. | :ref:`bool<class_bool>` | toggle_mode | ``true`` *(parent override)* |
  27. +-----------------------------------------------+-------------------------------------------------------------------+------------------------------+
  28. Methods
  29. -------
  30. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_popup<class_MenuButton_method_get_popup>` **(** **)** |const| |
  32. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`set_disable_shortcuts<class_MenuButton_method_set_disable_shortcuts>` **(** :ref:`bool<class_bool>` disabled **)** |
  34. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  35. Theme Properties
  36. ----------------
  37. +---------------------------------+---------------------+------------------------------+
  38. | :ref:`StyleBox<class_StyleBox>` | disabled | |
  39. +---------------------------------+---------------------+------------------------------+
  40. | :ref:`StyleBox<class_StyleBox>` | focus | |
  41. +---------------------------------+---------------------+------------------------------+
  42. | :ref:`Font<class_Font>` | font | |
  43. +---------------------------------+---------------------+------------------------------+
  44. | :ref:`Color<class_Color>` | font_color | Color( 0.88, 0.88, 0.88, 1 ) |
  45. +---------------------------------+---------------------+------------------------------+
  46. | :ref:`Color<class_Color>` | font_color_disabled | Color( 1, 1, 1, 0.3 ) |
  47. +---------------------------------+---------------------+------------------------------+
  48. | :ref:`Color<class_Color>` | font_color_hover | Color( 0.94, 0.94, 0.94, 1 ) |
  49. +---------------------------------+---------------------+------------------------------+
  50. | :ref:`Color<class_Color>` | font_color_pressed | Color( 1, 1, 1, 1 ) |
  51. +---------------------------------+---------------------+------------------------------+
  52. | :ref:`StyleBox<class_StyleBox>` | hover | |
  53. +---------------------------------+---------------------+------------------------------+
  54. | :ref:`int<class_int>` | hseparation | 3 |
  55. +---------------------------------+---------------------+------------------------------+
  56. | :ref:`StyleBox<class_StyleBox>` | normal | |
  57. +---------------------------------+---------------------+------------------------------+
  58. | :ref:`StyleBox<class_StyleBox>` | pressed | |
  59. +---------------------------------+---------------------+------------------------------+
  60. Signals
  61. -------
  62. .. _class_MenuButton_signal_about_to_show:
  63. - **about_to_show** **(** **)**
  64. Emitted when :ref:`PopupMenu<class_PopupMenu>` of this MenuButton is about to show.
  65. Property Descriptions
  66. ---------------------
  67. .. _class_MenuButton_property_switch_on_hover:
  68. - :ref:`bool<class_bool>` **switch_on_hover**
  69. +-----------+----------------------------+
  70. | *Default* | ``false`` |
  71. +-----------+----------------------------+
  72. | *Setter* | set_switch_on_hover(value) |
  73. +-----------+----------------------------+
  74. | *Getter* | is_switch_on_hover() |
  75. +-----------+----------------------------+
  76. 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.
  77. Method Descriptions
  78. -------------------
  79. .. _class_MenuButton_method_get_popup:
  80. - :ref:`PopupMenu<class_PopupMenu>` **get_popup** **(** **)** |const|
  81. Returns the :ref:`PopupMenu<class_PopupMenu>` contained in this button.
  82. ----
  83. .. _class_MenuButton_method_set_disable_shortcuts:
  84. - void **set_disable_shortcuts** **(** :ref:`bool<class_bool>` disabled **)**
  85. If ``true``, shortcuts are disabled and cannot be used to trigger the button.
  86. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  87. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  88. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`