| 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="toggled_on" 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. |
| 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] Changing the value of [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" keywords="enabled"> |
| 63 | If [code]true[/code], the button is in disabled state and can't be clicked or toggled. |
| 64 | [b]Note:[/b] If the button is disabled while held down, [signal button_up] will be emitted. |
| 65 | </member> |
| 66 | <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> |
| 67 | <member name="keep_pressed_outside" type="bool" setter="set_keep_pressed_outside" getter="is_keep_pressed_outside" default="false"> |
| 68 | If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it. |
| 69 | [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. |
| 70 | </member> |
| 71 | <member name="shortcut" type="Shortcut" setter="set_shortcut" getter="get_shortcut"> |
| 72 | [Shortcut] associated to the button. |
| 73 | </member> |
| 74 | <member name="shortcut_feedback" type="bool" setter="set_shortcut_feedback" getter="is_shortcut_feedback" default="true"> |
| 75 | 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. |
| 76 | </member> |
| 77 | <member name="shortcut_in_tooltip" type="bool" setter="set_shortcut_in_tooltip" getter="is_shortcut_in_tooltip_enabled" default="true"> |
| 78 | If [code]true[/code], the button will add information about its shortcut in the tooltip. |
| 79 | [b]Note:[/b] This property does nothing when the tooltip control is customized using [method Control._make_custom_tooltip]. |
| 80 | </member> |
| 81 | <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" default="false"> |
| 82 | 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. |
| 83 | </member> |
| 84 | </members> |
| 85 | <signals> |
| 86 | <signal name="button_down"> |
| 87 | <description> |
| 88 | Emitted when the button starts being held down. |
| 89 | </description> |
| 90 | </signal> |
| 91 | <signal name="button_up"> |
| 92 | <description> |
| 93 | Emitted when the button stops being held down. |
| 94 | </description> |
| 95 | </signal> |
| 96 | <signal name="pressed"> |
| 97 | <description> |
| 98 | 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. |
| 99 | If you need to know the button's pressed state (and [member toggle_mode] is active), use [signal toggled] instead. |
| 100 | </description> |
| 101 | </signal> |
| 102 | <signal name="toggled"> |
| 103 | <param index="0" name="toggled_on" type="bool" /> |
| 104 | <description> |
| 105 | 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 toggled_on] argument. |
| 106 | </description> |
| 107 | </signal> |
| 108 | </signals> |
| 109 | <constants> |
| 110 | <constant name="DRAW_NORMAL" value="0" enum="DrawMode"> |
| 111 | The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons. |
| 112 | </constant> |
| 113 | <constant name="DRAW_PRESSED" value="1" enum="DrawMode"> |
| 114 | The state of buttons are pressed. |
| 115 | </constant> |
| 116 | <constant name="DRAW_HOVER" value="2" enum="DrawMode"> |
| 117 | The state of buttons are hovered. |
| 118 | </constant> |
| 119 | <constant name="DRAW_DISABLED" value="3" enum="DrawMode"> |
| 120 | The state of buttons are disabled. |
| 121 | </constant> |
| 122 | <constant name="DRAW_HOVER_PRESSED" value="4" enum="DrawMode"> |
| 123 | The state of buttons are both hovered and pressed. |
| 124 | </constant> |
| 125 | <constant name="ACTION_MODE_BUTTON_PRESS" value="0" enum="ActionMode"> |
| 126 | Require just a press to consider the button clicked. |
| 127 | </constant> |
| 128 | <constant name="ACTION_MODE_BUTTON_RELEASE" value="1" enum="ActionMode"> |
| 129 | Require a press and a subsequent release before considering the button clicked. |
| 130 | </constant> |
| 131 | </constants> |
| 132 | </class> |