class_basebutton.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the BaseButton.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_BaseButton:
  5. BaseButton
  6. ==========
  7. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  8. **Inherited By:** :ref:`Button<class_Button>`, :ref:`LinkButton<class_LinkButton>`, :ref:`TextureButton<class_TextureButton>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Base class for different kinds of buttons.
  13. Properties
  14. ----------
  15. +-----------------------------------------------+------------------------------------------------------------------+
  16. | :ref:`ActionMode<enum_BaseButton_ActionMode>` | :ref:`action_mode<class_BaseButton_action_mode>` |
  17. +-----------------------------------------------+------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`button_mask<class_BaseButton_button_mask>` |
  19. +-----------------------------------------------+------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`disabled<class_BaseButton_disabled>` |
  21. +-----------------------------------------------+------------------------------------------------------------------+
  22. | :ref:`FocusMode<enum_Control_FocusMode>` | :ref:`enabled_focus_mode<class_BaseButton_enabled_focus_mode>` |
  23. +-----------------------------------------------+------------------------------------------------------------------+
  24. | :ref:`ButtonGroup<class_ButtonGroup>` | :ref:`group<class_BaseButton_group>` |
  25. +-----------------------------------------------+------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`pressed<class_BaseButton_pressed>` |
  27. +-----------------------------------------------+------------------------------------------------------------------+
  28. | :ref:`ShortCut<class_ShortCut>` | :ref:`shortcut<class_BaseButton_shortcut>` |
  29. +-----------------------------------------------+------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`shortcut_in_tooltip<class_BaseButton_shortcut_in_tooltip>` |
  31. +-----------------------------------------------+------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`toggle_mode<class_BaseButton_toggle_mode>` |
  33. +-----------------------------------------------+------------------------------------------------------------------+
  34. Methods
  35. -------
  36. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`_pressed<class_BaseButton__pressed>` **(** **)** virtual |
  38. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`_toggled<class_BaseButton__toggled>` **(** :ref:`bool<class_bool>` button_pressed **)** virtual |
  40. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  41. | :ref:`DrawMode<enum_BaseButton_DrawMode>` | :ref:`get_draw_mode<class_BaseButton_get_draw_mode>` **(** **)** const |
  42. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_hovered<class_BaseButton_is_hovered>` **(** **)** const |
  44. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  45. Signals
  46. -------
  47. .. _class_BaseButton_button_down:
  48. - **button_down** **(** **)**
  49. Emitted when the button starts being held down.
  50. .. _class_BaseButton_button_up:
  51. - **button_up** **(** **)**
  52. Emitted when the button stops being held down.
  53. .. _class_BaseButton_pressed:
  54. - **pressed** **(** **)**
  55. This signal is emitted every time the button is toggled or pressed (i.e. activated, so on ``button_down`` if "Click on press" is active and on ``button_up`` otherwise).
  56. .. _class_BaseButton_toggled:
  57. - **toggled** **(** :ref:`bool<class_bool>` button_pressed **)**
  58. This signal is emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the *pressed* argument.
  59. Enumerations
  60. ------------
  61. .. _enum_BaseButton_DrawMode:
  62. enum **DrawMode**:
  63. - **DRAW_NORMAL** = **0** --- The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
  64. - **DRAW_PRESSED** = **1** --- The state of buttons are pressed.
  65. - **DRAW_HOVER** = **2** --- The state of buttons are hovered.
  66. - **DRAW_DISABLED** = **3** --- The state of buttons are disabled.
  67. - **DRAW_HOVER_PRESSED** = **4**
  68. .. _enum_BaseButton_ActionMode:
  69. enum **ActionMode**:
  70. - **ACTION_MODE_BUTTON_PRESS** = **0** --- Require just a press to consider the button clicked.
  71. - **ACTION_MODE_BUTTON_RELEASE** = **1** --- Require a press and a subsequent release before considering the button clicked.
  72. Description
  73. -----------
  74. BaseButton is the abstract base class for buttons, so it shouldn't be used directly (it doesn't display anything). Other types of buttons inherit from it.
  75. Property Descriptions
  76. ---------------------
  77. .. _class_BaseButton_action_mode:
  78. - :ref:`ActionMode<enum_BaseButton_ActionMode>` **action_mode**
  79. +----------+------------------------+
  80. | *Setter* | set_action_mode(value) |
  81. +----------+------------------------+
  82. | *Getter* | get_action_mode() |
  83. +----------+------------------------+
  84. Determines when the button is considered clicked, one of the ACTION_MODE\_\* constants.
  85. .. _class_BaseButton_button_mask:
  86. - :ref:`int<class_int>` **button_mask**
  87. +----------+------------------------+
  88. | *Setter* | set_button_mask(value) |
  89. +----------+------------------------+
  90. | *Getter* | get_button_mask() |
  91. +----------+------------------------+
  92. Binary mask to choose which mouse buttons this button will respond to.
  93. To allow both left-click and right-click, set this to 3, because it's BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT.
  94. .. _class_BaseButton_disabled:
  95. - :ref:`bool<class_bool>` **disabled**
  96. +----------+---------------------+
  97. | *Setter* | set_disabled(value) |
  98. +----------+---------------------+
  99. | *Getter* | is_disabled() |
  100. +----------+---------------------+
  101. If ``true``, the button is in disabled state and can't be clicked or toggled.
  102. .. _class_BaseButton_enabled_focus_mode:
  103. - :ref:`FocusMode<enum_Control_FocusMode>` **enabled_focus_mode**
  104. +----------+-------------------------------+
  105. | *Setter* | set_enabled_focus_mode(value) |
  106. +----------+-------------------------------+
  107. | *Getter* | get_enabled_focus_mode() |
  108. +----------+-------------------------------+
  109. Focus access mode to use when switching between enabled/disabled (see :ref:`Control.set_focus_mode<class_Control_set_focus_mode>` and :ref:`disabled<class_BaseButton_disabled>`).
  110. .. _class_BaseButton_group:
  111. - :ref:`ButtonGroup<class_ButtonGroup>` **group**
  112. +----------+-------------------------+
  113. | *Setter* | set_button_group(value) |
  114. +----------+-------------------------+
  115. | *Getter* | get_button_group() |
  116. +----------+-------------------------+
  117. :ref:`ButtonGroup<class_ButtonGroup>` associated to the button.
  118. .. _class_BaseButton_pressed:
  119. - :ref:`bool<class_bool>` **pressed**
  120. +----------+--------------------+
  121. | *Setter* | set_pressed(value) |
  122. +----------+--------------------+
  123. | *Getter* | is_pressed() |
  124. +----------+--------------------+
  125. If ``true``, the button's state is pressed. Means the button is pressed down or toggled (if toggle_mode is active).
  126. .. _class_BaseButton_shortcut:
  127. - :ref:`ShortCut<class_ShortCut>` **shortcut**
  128. +----------+---------------------+
  129. | *Setter* | set_shortcut(value) |
  130. +----------+---------------------+
  131. | *Getter* | get_shortcut() |
  132. +----------+---------------------+
  133. Shortcut associated to the button.
  134. .. _class_BaseButton_shortcut_in_tooltip:
  135. - :ref:`bool<class_bool>` **shortcut_in_tooltip**
  136. +----------+----------------------------------+
  137. | *Setter* | set_shortcut_in_tooltip(value) |
  138. +----------+----------------------------------+
  139. | *Getter* | is_shortcut_in_tooltip_enabled() |
  140. +----------+----------------------------------+
  141. If ``true``, the button will add information about its shortcut in the tooltip.
  142. .. _class_BaseButton_toggle_mode:
  143. - :ref:`bool<class_bool>` **toggle_mode**
  144. +----------+------------------------+
  145. | *Setter* | set_toggle_mode(value) |
  146. +----------+------------------------+
  147. | *Getter* | is_toggle_mode() |
  148. +----------+------------------------+
  149. If ``true``, the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked.
  150. Method Descriptions
  151. -------------------
  152. .. _class_BaseButton__pressed:
  153. - void **_pressed** **(** **)** virtual
  154. Called when the button is pressed.
  155. .. _class_BaseButton__toggled:
  156. - void **_toggled** **(** :ref:`bool<class_bool>` button_pressed **)** virtual
  157. Called when the button is toggled (only if toggle_mode is active).
  158. .. _class_BaseButton_get_draw_mode:
  159. - :ref:`DrawMode<enum_BaseButton_DrawMode>` **get_draw_mode** **(** **)** const
  160. Return the visual state used to draw the button. This is useful mainly when implementing your own draw code by either overriding _draw() or connecting to "draw" signal. The visual state of the button is defined by the DRAW\_\* enum.
  161. .. _class_BaseButton_is_hovered:
  162. - :ref:`bool<class_bool>` **is_hovered** **(** **)** const
  163. Return true if the mouse has entered the button and has not left it yet.