BaseButton.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="BaseButton" inherits="Control" version="3.2">
  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. </return>
  15. <description>
  16. Called when the button is pressed.
  17. </description>
  18. </method>
  19. <method name="_toggled" qualifiers="virtual">
  20. <return type="void">
  21. </return>
  22. <argument index="0" name="button_pressed" type="bool">
  23. </argument>
  24. <description>
  25. Called when the button is toggled (only if [member toggle_mode] is active).
  26. </description>
  27. </method>
  28. <method name="get_draw_mode" qualifiers="const">
  29. <return type="int" enum="BaseButton.DrawMode">
  30. </return>
  31. <description>
  32. 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.
  33. </description>
  34. </method>
  35. <method name="is_hovered" qualifiers="const">
  36. <return type="bool">
  37. </return>
  38. <description>
  39. Returns [code]true[/code] if the mouse has entered the button and has not left it yet.
  40. </description>
  41. </method>
  42. </methods>
  43. <members>
  44. <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="BaseButton.ActionMode" default="1">
  45. Determines when the button is considered clicked, one of the [enum ActionMode] constants.
  46. </member>
  47. <member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" default="1">
  48. Binary mask to choose which mouse buttons this button will respond to.
  49. To allow both left-click and right-click, use [code]BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT[/code].
  50. </member>
  51. <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false">
  52. If [code]true[/code], the button is in disabled state and can't be clicked or toggled.
  53. </member>
  54. <member name="enabled_focus_mode" type="int" setter="set_enabled_focus_mode" getter="get_enabled_focus_mode" enum="Control.FocusMode" default="2">
  55. Focus access mode to use when switching between enabled/disabled (see [member Control.focus_mode] and [member disabled]).
  56. </member>
  57. <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" />
  58. <member name="group" type="ButtonGroup" setter="set_button_group" getter="get_button_group">
  59. [ButtonGroup] associated to the button.
  60. </member>
  61. <member name="keep_pressed_outside" type="bool" setter="set_keep_pressed_outside" getter="is_keep_pressed_outside" default="false">
  62. If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it.
  63. </member>
  64. <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
  65. If [code]true[/code], the button's state is pressed. Means the button is pressed down or toggled (if [member toggle_mode] is active).
  66. </member>
  67. <member name="shortcut" type="ShortCut" setter="set_shortcut" getter="get_shortcut">
  68. [ShortCut] associated to the button.
  69. </member>
  70. <member name="shortcut_in_tooltip" type="bool" setter="set_shortcut_in_tooltip" getter="is_shortcut_in_tooltip_enabled" default="true">
  71. If [code]true[/code], the button will add information about its shortcut in the tooltip.
  72. </member>
  73. <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" default="false">
  74. 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.
  75. </member>
  76. </members>
  77. <signals>
  78. <signal name="button_down">
  79. <description>
  80. Emitted when the button starts being held down.
  81. </description>
  82. </signal>
  83. <signal name="button_up">
  84. <description>
  85. Emitted when the button stops being held down.
  86. </description>
  87. </signal>
  88. <signal name="pressed">
  89. <description>
  90. 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.
  91. </description>
  92. </signal>
  93. <signal name="toggled">
  94. <argument index="0" name="button_pressed" type="bool">
  95. </argument>
  96. <description>
  97. 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.
  98. </description>
  99. </signal>
  100. </signals>
  101. <constants>
  102. <constant name="DRAW_NORMAL" value="0" enum="DrawMode">
  103. The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
  104. </constant>
  105. <constant name="DRAW_PRESSED" value="1" enum="DrawMode">
  106. The state of buttons are pressed.
  107. </constant>
  108. <constant name="DRAW_HOVER" value="2" enum="DrawMode">
  109. The state of buttons are hovered.
  110. </constant>
  111. <constant name="DRAW_DISABLED" value="3" enum="DrawMode">
  112. The state of buttons are disabled.
  113. </constant>
  114. <constant name="DRAW_HOVER_PRESSED" value="4" enum="DrawMode">
  115. The state of buttons are both hovered and pressed.
  116. </constant>
  117. <constant name="ACTION_MODE_BUTTON_PRESS" value="0" enum="ActionMode">
  118. Require just a press to consider the button clicked.
  119. </constant>
  120. <constant name="ACTION_MODE_BUTTON_RELEASE" value="1" enum="ActionMode">
  121. Require a press and a subsequent release before considering the button clicked.
  122. </constant>
  123. </constants>
  124. </class>