BaseButton.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="BaseButton" inherits="Control" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Base class for different kinds of buttons.
  5. </brief_description>
  6. <description>
  7. 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.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="_pressed" qualifiers="virtual">
  13. <return type="void" />
  14. <description>
  15. Called when the button is pressed. If you need to know the button's pressed state (and [member toggle_mode] is active), use [method _toggled] instead.
  16. </description>
  17. </method>
  18. <method name="_toggled" qualifiers="virtual">
  19. <return type="void" />
  20. <argument index="0" name="button_pressed" type="bool" />
  21. <description>
  22. Called when the button is toggled (only if [member toggle_mode] is active).
  23. </description>
  24. </method>
  25. <method name="get_draw_mode" qualifiers="const">
  26. <return type="int" enum="BaseButton.DrawMode" />
  27. <description>
  28. Returns 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 [enum DrawMode] enum.
  29. </description>
  30. </method>
  31. <method name="is_hovered" qualifiers="const">
  32. <return type="bool" />
  33. <description>
  34. Returns [code]true[/code] if the mouse has entered the button and has not left it yet.
  35. </description>
  36. </method>
  37. <method name="set_pressed_no_signal">
  38. <return type="void" />
  39. <argument index="0" name="pressed" type="bool" />
  40. <description>
  41. Changes the [member pressed] state of the button, without emitting [signal toggled]. Use when you just want to change the state of the button without sending the pressed event (e.g. when initializing scene). Only works if [member toggle_mode] is [code]true[/code].
  42. [b]Note:[/b] This method doesn't unpress other buttons in its button [member group].
  43. </description>
  44. </method>
  45. </methods>
  46. <members>
  47. <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="BaseButton.ActionMode" default="1">
  48. Determines when the button is considered clicked, one of the [enum ActionMode] constants.
  49. </member>
  50. <member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" default="1">
  51. Binary mask to choose which mouse buttons this button will respond to.
  52. To allow both left-click and right-click, use [code]BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT[/code].
  53. </member>
  54. <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false">
  55. If [code]true[/code], the button is in disabled state and can't be clicked or toggled.
  56. </member>
  57. <member name="enabled_focus_mode" type="int" setter="set_enabled_focus_mode" getter="get_enabled_focus_mode" enum="Control.FocusMode" default="2">
  58. [i]Deprecated.[/i] This property has been deprecated due to redundancy and will be removed in Godot 4.0. This property no longer has any effect when set. Please use [member Control.focus_mode] instead.
  59. </member>
  60. <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
  61. <member name="group" type="ButtonGroup" setter="set_button_group" getter="get_button_group">
  62. [ButtonGroup] associated to the button.
  63. </member>
  64. <member name="keep_pressed_outside" type="bool" setter="set_keep_pressed_outside" getter="is_keep_pressed_outside" default="false">
  65. If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it.
  66. [b]Note:[/b] This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value.
  67. </member>
  68. <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
  69. If [code]true[/code], the button's state is pressed. Means the button is pressed down or toggled (if [member toggle_mode] is active). Only works if [member toggle_mode] is [code]true[/code].
  70. [b]Note:[/b] Setting [member pressed] will result in [signal toggled] to be emitted. If you want to change the pressed state without emitting that signal, use [method set_pressed_no_signal].
  71. </member>
  72. <member name="shortcut" type="ShortCut" setter="set_shortcut" getter="get_shortcut">
  73. [ShortCut] associated to the button.
  74. </member>
  75. <member name="shortcut_in_tooltip" type="bool" setter="set_shortcut_in_tooltip" getter="is_shortcut_in_tooltip_enabled" default="true">
  76. If [code]true[/code], the button will add information about its shortcut in the tooltip.
  77. </member>
  78. <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" default="false">
  79. If [code]true[/code], the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked.
  80. </member>
  81. </members>
  82. <signals>
  83. <signal name="button_down">
  84. <description>
  85. Emitted when the button starts being held down.
  86. </description>
  87. </signal>
  88. <signal name="button_up">
  89. <description>
  90. Emitted when the button stops being held down.
  91. </description>
  92. </signal>
  93. <signal name="pressed">
  94. <description>
  95. Emitted when the button is toggled or pressed. This is on [signal button_down] if [member action_mode] is [constant ACTION_MODE_BUTTON_PRESS] and on [signal button_up] otherwise.
  96. If you need to know the button's pressed state (and [member toggle_mode] is active), use [signal toggled] instead.
  97. </description>
  98. </signal>
  99. <signal name="toggled">
  100. <argument index="0" name="button_pressed" type="bool" />
  101. <description>
  102. Emitted when the button was just toggled between pressed and normal states (only if [member toggle_mode] is active). The new state is contained in the [code]button_pressed[/code] argument.
  103. </description>
  104. </signal>
  105. </signals>
  106. <constants>
  107. <constant name="DRAW_NORMAL" value="0" enum="DrawMode">
  108. The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
  109. </constant>
  110. <constant name="DRAW_PRESSED" value="1" enum="DrawMode">
  111. The state of buttons are pressed.
  112. </constant>
  113. <constant name="DRAW_HOVER" value="2" enum="DrawMode">
  114. The state of buttons are hovered.
  115. </constant>
  116. <constant name="DRAW_DISABLED" value="3" enum="DrawMode">
  117. The state of buttons are disabled.
  118. </constant>
  119. <constant name="DRAW_HOVER_PRESSED" value="4" enum="DrawMode">
  120. The state of buttons are both hovered and pressed.
  121. </constant>
  122. <constant name="ACTION_MODE_BUTTON_PRESS" value="0" enum="ActionMode">
  123. Require just a press to consider the button clicked.
  124. </constant>
  125. <constant name="ACTION_MODE_BUTTON_RELEASE" value="1" enum="ActionMode">
  126. Require a press and a subsequent release before considering the button clicked.
  127. </constant>
  128. </constants>
  129. </class>