class_basebutton.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_BaseButton:
  4. BaseButton
  5. ==========
  6. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`LinkButton<class_linkbutton>`, :ref:`TextureButton<class_texturebutton>`, :ref:`Button<class_button>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Provides a base class for different kinds of buttons.
  12. Member Functions
  13. ----------------
  14. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`_pressed<class_BaseButton__pressed>` **(** **)** virtual |
  16. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`_toggled<class_BaseButton__toggled>` **(** :ref:`bool<class_bool>` pressed **)** virtual |
  18. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`get_click_on_press<class_BaseButton_get_click_on_press>` **(** **)** const |
  20. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`get_draw_mode<class_BaseButton_get_draw_mode>` **(** **)** const |
  22. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_enabled_focus_mode<class_BaseButton_get_enabled_focus_mode>` **(** **)** const |
  24. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Object<class_object>` | :ref:`get_shortcut<class_BaseButton_get_shortcut>` **(** **)** const |
  26. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`is_disabled<class_BaseButton_is_disabled>` **(** **)** const |
  28. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`is_hovered<class_BaseButton_is_hovered>` **(** **)** const |
  30. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_pressed<class_BaseButton_is_pressed>` **(** **)** const |
  32. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`is_toggle_mode<class_BaseButton_is_toggle_mode>` **(** **)** const |
  34. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_click_on_press<class_BaseButton_set_click_on_press>` **(** :ref:`bool<class_bool>` enable **)** |
  36. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_disabled<class_BaseButton_set_disabled>` **(** :ref:`bool<class_bool>` disabled **)** |
  38. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_enabled_focus_mode<class_BaseButton_set_enabled_focus_mode>` **(** :ref:`int<class_int>` mode **)** |
  40. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_pressed<class_BaseButton_set_pressed>` **(** :ref:`bool<class_bool>` pressed **)** |
  42. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_shortcut<class_BaseButton_set_shortcut>` **(** :ref:`Object<class_object>` shortcut **)** |
  44. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_toggle_mode<class_BaseButton_set_toggle_mode>` **(** :ref:`bool<class_bool>` enabled **)** |
  46. +------------------------------+-----------------------------------------------------------------------------------------------------------------+
  47. Signals
  48. -------
  49. - **button_down** **(** **)**
  50. Emitted when the button starts being held down.
  51. - **button_up** **(** **)**
  52. Emitted when the button stops being held down.
  53. - **pressed** **(** **)**
  54. 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).
  55. - **released** **(** **)**
  56. Emitted when the button was released. This is only emitted by non-toggle buttons and if "Click on press" is active.
  57. - **toggled** **(** :ref:`bool<class_bool>` 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. Numeric Constants
  60. -----------------
  61. - **DRAW_NORMAL** = **0** --- The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
  62. - **DRAW_PRESSED** = **1** --- The state of buttons are pressed.
  63. - **DRAW_HOVER** = **2** --- The state of buttons are hovered.
  64. - **DRAW_DISABLED** = **3** --- The state of buttons are disabled.
  65. Description
  66. -----------
  67. 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.
  68. Member Function Description
  69. ---------------------------
  70. .. _class_BaseButton__pressed:
  71. - void **_pressed** **(** **)** virtual
  72. Called when button is pressed.
  73. .. _class_BaseButton__toggled:
  74. - void **_toggled** **(** :ref:`bool<class_bool>` pressed **)** virtual
  75. Called when button is toggled (only if toggle_mode is active).
  76. .. _class_BaseButton_get_click_on_press:
  77. - :ref:`bool<class_bool>` **get_click_on_press** **(** **)** const
  78. Return the state of the click_on_press property (see :ref:`set_click_on_press<class_BaseButton_set_click_on_press>`).
  79. .. _class_BaseButton_get_draw_mode:
  80. - :ref:`int<class_int>` **get_draw_mode** **(** **)** const
  81. 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.
  82. .. _class_BaseButton_get_enabled_focus_mode:
  83. - :ref:`int<class_int>` **get_enabled_focus_mode** **(** **)** const
  84. Returns focus access mode used when switching between enabled/disabled (see :ref:`Control.set_focus_mode<class_Control_set_focus_mode>` and :ref:`set_disabled<class_BaseButton_set_disabled>`).
  85. .. _class_BaseButton_get_shortcut:
  86. - :ref:`Object<class_object>` **get_shortcut** **(** **)** const
  87. .. _class_BaseButton_is_disabled:
  88. - :ref:`bool<class_bool>` **is_disabled** **(** **)** const
  89. Return whether the button is in disabled state (see :ref:`set_disabled<class_BaseButton_set_disabled>`).
  90. .. _class_BaseButton_is_hovered:
  91. - :ref:`bool<class_bool>` **is_hovered** **(** **)** const
  92. Return true if mouse entered the button before it exit.
  93. .. _class_BaseButton_is_pressed:
  94. - :ref:`bool<class_bool>` **is_pressed** **(** **)** const
  95. If toggle_mode is active, return whether the button is toggled. If toggle_mode is not active, return whether the button is pressed down.
  96. .. _class_BaseButton_is_toggle_mode:
  97. - :ref:`bool<class_bool>` **is_toggle_mode** **(** **)** const
  98. Return the toggle_mode property (see :ref:`set_toggle_mode<class_BaseButton_set_toggle_mode>`).
  99. .. _class_BaseButton_set_click_on_press:
  100. - void **set_click_on_press** **(** :ref:`bool<class_bool>` enable **)**
  101. Set the button click_on_press mode. This mode generates click events when a mouse button or key is just pressed (by default events are generated when the button/keys are released and both press and release occur in the visual area of the Button).
  102. .. _class_BaseButton_set_disabled:
  103. - void **set_disabled** **(** :ref:`bool<class_bool>` disabled **)**
  104. Set the button into disabled state. When a button is disabled, it can't be clicked or toggled.
  105. .. _class_BaseButton_set_enabled_focus_mode:
  106. - void **set_enabled_focus_mode** **(** :ref:`int<class_int>` mode **)**
  107. Sets the focus access mode to use when switching between enabled/disabled (see :ref:`Control.set_focus_mode<class_Control_set_focus_mode>` and :ref:`set_disabled<class_BaseButton_set_disabled>`).
  108. .. _class_BaseButton_set_pressed:
  109. - void **set_pressed** **(** :ref:`bool<class_bool>` pressed **)**
  110. Set the button to pressed state (only if toggle_mode is active).
  111. .. _class_BaseButton_set_shortcut:
  112. - void **set_shortcut** **(** :ref:`Object<class_object>` shortcut **)**
  113. .. _class_BaseButton_set_toggle_mode:
  114. - void **set_toggle_mode** **(** :ref:`bool<class_bool>` enabled **)**
  115. Set the button toggle_mode property. Toggle mode makes the button flip state between pressed and unpressed each time its area is clicked.