BaseButton.xml 7.1 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. Abstract base class for GUI buttons.
  5. </brief_description>
  6. <description>
  7. [BaseButton] is an abstract base class for GUI buttons. It doesn't display anything by itself.
  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. <param 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. <param index="0" name="pressed" type="bool" />
  40. <description>
  41. Changes the [member button_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 [member button_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_group" type="ButtonGroup" setter="set_button_group" getter="get_button_group">
  51. The [ButtonGroup] associated with the button. Not to be confused with node groups.
  52. [b]Note:[/b] The button will be configured as a radio button if a [ButtonGroup] is assigned to it.
  53. </member>
  54. <member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" enum="MouseButtonMask" is_bitfield="true" default="1">
  55. Binary mask to choose which mouse buttons this button will respond to.
  56. To allow both left-click and right-click, use [code]MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT[/code].
  57. </member>
  58. <member name="button_pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
  59. 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].
  60. [b]Note:[/b] Setting [member button_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].
  61. </member>
  62. <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false">
  63. If [code]true[/code], the button is in disabled state and can't be clicked or toggled.
  64. </member>
  65. <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
  66. <member name="keep_pressed_outside" type="bool" setter="set_keep_pressed_outside" getter="is_keep_pressed_outside" default="false">
  67. If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it.
  68. [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.
  69. </member>
  70. <member name="shortcut" type="Shortcut" setter="set_shortcut" getter="get_shortcut">
  71. [Shortcut] associated to the button.
  72. </member>
  73. <member name="shortcut_feedback" type="bool" setter="set_shortcut_feedback" getter="is_shortcut_feedback" default="true">
  74. If [code]true[/code], the button will highlight for a short amount of time when its shortcut is activated. If [code]false[/code] and [member toggle_mode] is [code]false[/code], the shortcut will activate without any visual feedback.
  75. </member>
  76. <member name="shortcut_in_tooltip" type="bool" setter="set_shortcut_in_tooltip" getter="is_shortcut_in_tooltip_enabled" default="true">
  77. If [code]true[/code], the button will add information about its shortcut in the tooltip.
  78. </member>
  79. <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" default="false">
  80. 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.
  81. </member>
  82. </members>
  83. <signals>
  84. <signal name="button_down">
  85. <description>
  86. Emitted when the button starts being held down.
  87. </description>
  88. </signal>
  89. <signal name="button_up">
  90. <description>
  91. Emitted when the button stops being held down.
  92. </description>
  93. </signal>
  94. <signal name="pressed">
  95. <description>
  96. 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.
  97. If you need to know the button's pressed state (and [member toggle_mode] is active), use [signal toggled] instead.
  98. </description>
  99. </signal>
  100. <signal name="toggled">
  101. <param index="0" name="button_pressed" type="bool" />
  102. <description>
  103. 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 [param button_pressed] argument.
  104. </description>
  105. </signal>
  106. </signals>
  107. <constants>
  108. <constant name="DRAW_NORMAL" value="0" enum="DrawMode">
  109. The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
  110. </constant>
  111. <constant name="DRAW_PRESSED" value="1" enum="DrawMode">
  112. The state of buttons are pressed.
  113. </constant>
  114. <constant name="DRAW_HOVER" value="2" enum="DrawMode">
  115. The state of buttons are hovered.
  116. </constant>
  117. <constant name="DRAW_DISABLED" value="3" enum="DrawMode">
  118. The state of buttons are disabled.
  119. </constant>
  120. <constant name="DRAW_HOVER_PRESSED" value="4" enum="DrawMode">
  121. The state of buttons are both hovered and pressed.
  122. </constant>
  123. <constant name="ACTION_MODE_BUTTON_PRESS" value="0" enum="ActionMode">
  124. Require just a press to consider the button clicked.
  125. </constant>
  126. <constant name="ACTION_MODE_BUTTON_RELEASE" value="1" enum="ActionMode">
  127. Require a press and a subsequent release before considering the button clicked.
  128. </constant>
  129. </constants>
  130. </class>