class_basebutton.rst 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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:`LinkButton<class_LinkButton>`, :ref:`TextureButton<class_TextureButton>`, :ref:`Button<class_Button>`
  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:`toggle_mode<class_BaseButton_toggle_mode>` |
  31. +-----------------------------------------------+----------------------------------------------------------------+
  32. Methods
  33. -------
  34. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`_pressed<class_BaseButton__pressed>` **(** **)** virtual |
  36. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`_toggled<class_BaseButton__toggled>` **(** :ref:`bool<class_bool>` button_pressed **)** virtual |
  38. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  39. | :ref:`DrawMode<enum_BaseButton_DrawMode>` | :ref:`get_draw_mode<class_BaseButton_get_draw_mode>` **(** **)** const |
  40. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`is_hovered<class_BaseButton_is_hovered>` **(** **)** const |
  42. +--------------------------------------------+-------------------------------------------------------------------------------------------------------+
  43. Signals
  44. -------
  45. .. _class_BaseButton_button_down:
  46. - **button_down** **(** **)**
  47. Emitted when the button starts being held down.
  48. .. _class_BaseButton_button_up:
  49. - **button_up** **(** **)**
  50. Emitted when the button stops being held down.
  51. .. _class_BaseButton_pressed:
  52. - **pressed** **(** **)**
  53. 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).
  54. .. _class_BaseButton_toggled:
  55. - **toggled** **(** :ref:`bool<class_bool>` button_pressed **)**
  56. 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.
  57. Enumerations
  58. ------------
  59. .. _enum_BaseButton_ActionMode:
  60. enum **ActionMode**:
  61. - **ACTION_MODE_BUTTON_PRESS** = **0** --- Require just a press to consider the button clicked.
  62. - **ACTION_MODE_BUTTON_RELEASE** = **1** --- Require a press and a subsequent release before considering the button clicked.
  63. .. _enum_BaseButton_DrawMode:
  64. enum **DrawMode**:
  65. - **DRAW_NORMAL** = **0** --- The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
  66. - **DRAW_PRESSED** = **1** --- The state of buttons are pressed.
  67. - **DRAW_HOVER** = **2** --- The state of buttons are hovered.
  68. - **DRAW_DISABLED** = **3** --- The state of buttons are disabled.
  69. - **DRAW_HOVER_PRESSED** = **4**
  70. Description
  71. -----------
  72. 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.
  73. Property Descriptions
  74. ---------------------
  75. .. _class_BaseButton_action_mode:
  76. - :ref:`ActionMode<enum_BaseButton_ActionMode>` **action_mode**
  77. +----------+------------------------+
  78. | *Setter* | set_action_mode(value) |
  79. +----------+------------------------+
  80. | *Getter* | get_action_mode() |
  81. +----------+------------------------+
  82. Determines when the button is considered clicked, one of the ACTION_MODE\_\* constants.
  83. .. _class_BaseButton_button_mask:
  84. - :ref:`int<class_int>` **button_mask**
  85. +----------+------------------------+
  86. | *Setter* | set_button_mask(value) |
  87. +----------+------------------------+
  88. | *Getter* | get_button_mask() |
  89. +----------+------------------------+
  90. Binary mask to choose which mouse buttons this button will respond to.
  91. To allow both left-click and right-click, set this to 3, because it's BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT.
  92. .. _class_BaseButton_disabled:
  93. - :ref:`bool<class_bool>` **disabled**
  94. +----------+---------------------+
  95. | *Setter* | set_disabled(value) |
  96. +----------+---------------------+
  97. | *Getter* | is_disabled() |
  98. +----------+---------------------+
  99. If ``true`` the button is in disabled state and can't be clicked or toggled.
  100. .. _class_BaseButton_enabled_focus_mode:
  101. - :ref:`FocusMode<enum_Control_FocusMode>` **enabled_focus_mode**
  102. +----------+-------------------------------+
  103. | *Setter* | set_enabled_focus_mode(value) |
  104. +----------+-------------------------------+
  105. | *Getter* | get_enabled_focus_mode() |
  106. +----------+-------------------------------+
  107. 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>`).
  108. .. _class_BaseButton_group:
  109. - :ref:`ButtonGroup<class_ButtonGroup>` **group**
  110. +----------+-------------------------+
  111. | *Setter* | set_button_group(value) |
  112. +----------+-------------------------+
  113. | *Getter* | get_button_group() |
  114. +----------+-------------------------+
  115. :ref:`ButtonGroup<class_ButtonGroup>` associated to the button.
  116. .. _class_BaseButton_pressed:
  117. - :ref:`bool<class_bool>` **pressed**
  118. +----------+--------------------+
  119. | *Setter* | set_pressed(value) |
  120. +----------+--------------------+
  121. | *Getter* | is_pressed() |
  122. +----------+--------------------+
  123. If ``true`` the button's state is pressed. Means the button is pressed down or toggled (if toggle_mode is active).
  124. .. _class_BaseButton_shortcut:
  125. - :ref:`ShortCut<class_ShortCut>` **shortcut**
  126. +----------+---------------------+
  127. | *Setter* | set_shortcut(value) |
  128. +----------+---------------------+
  129. | *Getter* | get_shortcut() |
  130. +----------+---------------------+
  131. Shortcut associated to the button.
  132. .. _class_BaseButton_toggle_mode:
  133. - :ref:`bool<class_bool>` **toggle_mode**
  134. +----------+------------------------+
  135. | *Setter* | set_toggle_mode(value) |
  136. +----------+------------------------+
  137. | *Getter* | is_toggle_mode() |
  138. +----------+------------------------+
  139. If ``true`` the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked.
  140. Method Descriptions
  141. -------------------
  142. .. _class_BaseButton__pressed:
  143. - void **_pressed** **(** **)** virtual
  144. Called when the button is pressed.
  145. .. _class_BaseButton__toggled:
  146. - void **_toggled** **(** :ref:`bool<class_bool>` button_pressed **)** virtual
  147. Called when the button is toggled (only if toggle_mode is active).
  148. .. _class_BaseButton_get_draw_mode:
  149. - :ref:`DrawMode<enum_BaseButton_DrawMode>` **get_draw_mode** **(** **)** const
  150. 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.
  151. .. _class_BaseButton_is_hovered:
  152. - :ref:`bool<class_bool>` **is_hovered** **(** **)** const
  153. Return true if the mouse has entered the button and has not left it yet.