2017-09-13 04:42:36 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 16:08:05 +08:00
<class name= "BaseButton" inherits= "Control" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-13 04:42:36 +08:00
<brief_description >
2023-04-30 22:26:09 +08:00
Abstract base class for GUI buttons.
2017-09-13 04:42:36 +08:00
</brief_description>
<description >
2023-04-30 22:26:09 +08:00
[BaseButton] is an abstract base class for GUI buttons. It doesn't display anything by itself.
2017-09-13 04:42:36 +08:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "_pressed" qualifiers= "virtual" >
2021-07-30 21:28:05 +08:00
<return type= "void" />
2017-09-13 04:42:36 +08:00
<description >
2020-07-17 06:01:24 +08:00
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.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "_toggled" qualifiers= "virtual" >
2021-07-30 21:28:05 +08:00
<return type= "void" />
2023-07-05 22:54:40 +08:00
<param index= "0" name= "toggled_on" type= "bool" />
2017-09-13 04:42:36 +08:00
<description >
2019-12-07 06:09:20 +08:00
Called when the button is toggled (only if [member toggle_mode] is active).
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "get_draw_mode" qualifiers= "const" >
2021-07-30 21:28:05 +08:00
<return type= "int" enum= "BaseButton.DrawMode" />
2017-09-13 04:42:36 +08:00
<description >
2019-12-07 06:09:20 +08:00
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.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "is_hovered" qualifiers= "const" >
2021-07-30 21:28:05 +08:00
<return type= "bool" />
2017-09-13 04:42:36 +08:00
<description >
2019-05-24 10:15:43 +08:00
Returns [code]true[/code] if the mouse has entered the button and has not left it yet.
2017-09-13 04:42:36 +08:00
</description>
</method>
2021-05-06 20:33:44 +08:00
<method name= "set_pressed_no_signal" >
2021-07-30 21:28:05 +08:00
<return type= "void" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "pressed" type= "bool" />
2021-05-06 20:33:44 +08:00
<description >
2022-01-24 04:33:58 +08:00
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].
2021-05-06 20:33:44 +08:00
[b]Note:[/b] This method doesn't unpress other buttons in [member button_group].
</description>
</method>
2017-09-13 04:42:36 +08:00
</methods>
<members >
2022-11-07 03:27:24 +08:00
<member name= "action_mode" type= "int" setter= "set_action_mode" getter= "get_action_mode" enum= "BaseButton.ActionMode" default= "1" >
2019-12-07 06:09:20 +08:00
Determines when the button is considered clicked, one of the [enum ActionMode] constants.
2017-09-13 04:42:36 +08:00
</member>
2020-10-24 13:19:18 +08:00
<member name= "button_group" type= "ButtonGroup" setter= "set_button_group" getter= "get_button_group" >
The [ButtonGroup] associated with the button. Not to be confused with node groups.
2023-03-20 12:55:04 +08:00
[b]Note:[/b] The button will be configured as a radio button if a [ButtonGroup] is assigned to it.
2020-10-24 13:19:18 +08:00
</member>
2023-06-15 22:06:22 +08:00
<member name= "button_mask" type= "int" setter= "set_button_mask" getter= "get_button_mask" enum= "MouseButtonMask" is_bitfield= "true" default= "1" >
2018-03-12 01:19:18 +08:00
Binary mask to choose which mouse buttons this button will respond to.
2021-01-08 11:37:37 +08:00
To allow both left-click and right-click, use [code]MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT[/code].
2018-03-12 01:19:18 +08:00
</member>
2022-11-07 03:27:24 +08:00
<member name= "button_pressed" type= "bool" setter= "set_pressed" getter= "is_pressed" default= "false" >
2022-01-24 04:33:58 +08:00
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].
[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].
</member>
2024-02-22 01:51:08 +08:00
<member name= "disabled" type= "bool" setter= "set_disabled" getter= "is_disabled" default= "false" keywords= "enabled" >
2018-12-20 20:46:54 +08:00
If [code]true[/code], the button is in disabled state and can't be clicked or toggled.
2017-09-13 04:42:36 +08:00
</member>
2022-11-07 03:27:24 +08:00
<member name= "focus_mode" type= "int" setter= "set_focus_mode" getter= "get_focus_mode" overrides= "Control" enum= "Control.FocusMode" default= "2" />
<member name= "keep_pressed_outside" type= "bool" setter= "set_keep_pressed_outside" getter= "is_keep_pressed_outside" default= "false" >
2019-06-29 21:24:23 +08:00
If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it.
2020-04-14 03:56:47 +08:00
[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.
2019-05-15 18:51:58 +08:00
</member>
2020-09-10 03:53:24 +08:00
<member name= "shortcut" type= "Shortcut" setter= "set_shortcut" getter= "get_shortcut" >
[Shortcut] associated to the button.
2017-09-13 04:42:36 +08:00
</member>
2022-11-07 03:27:24 +08:00
<member name= "shortcut_feedback" type= "bool" setter= "set_shortcut_feedback" getter= "is_shortcut_feedback" default= "true" >
2023-01-13 20:59:38 +08:00
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.
2022-07-23 07:19:48 +08:00
</member>
2022-11-07 03:27:24 +08:00
<member name= "shortcut_in_tooltip" type= "bool" setter= "set_shortcut_in_tooltip" getter= "is_shortcut_in_tooltip_enabled" default= "true" >
2018-12-20 20:46:54 +08:00
If [code]true[/code], the button will add information about its shortcut in the tooltip.
2018-11-19 21:30:59 +08:00
</member>
2022-11-07 03:27:24 +08:00
<member name= "toggle_mode" type= "bool" setter= "set_toggle_mode" getter= "is_toggle_mode" default= "false" >
2018-12-20 20:46:54 +08:00
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.
2018-11-23 08:06:24 +08:00
</member>
2017-09-13 04:42:36 +08:00
</members>
<signals >
<signal name= "button_down" >
<description >
Emitted when the button starts being held down.
</description>
</signal>
<signal name= "button_up" >
<description >
Emitted when the button stops being held down.
</description>
</signal>
<signal name= "pressed" >
<description >
2019-06-22 07:04:47 +08:00
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.
2020-07-17 06:01:24 +08:00
If you need to know the button's pressed state (and [member toggle_mode] is active), use [signal toggled] instead.
2017-09-13 04:42:36 +08:00
</description>
</signal>
<signal name= "toggled" >
2023-07-05 22:54:40 +08:00
<param index= "0" name= "toggled_on" type= "bool" />
2017-09-13 04:42:36 +08:00
<description >
2023-07-05 22:54:40 +08:00
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.
2017-09-13 04:42:36 +08:00
</description>
</signal>
</signals>
<constants >
2017-11-25 06:16:30 +08:00
<constant name= "DRAW_NORMAL" value= "0" enum= "DrawMode" >
2017-09-13 04:42:36 +08:00
The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
</constant>
2017-11-25 06:16:30 +08:00
<constant name= "DRAW_PRESSED" value= "1" enum= "DrawMode" >
2017-09-13 04:42:36 +08:00
The state of buttons are pressed.
</constant>
2017-11-25 06:16:30 +08:00
<constant name= "DRAW_HOVER" value= "2" enum= "DrawMode" >
2017-09-13 04:42:36 +08:00
The state of buttons are hovered.
</constant>
2017-11-25 06:16:30 +08:00
<constant name= "DRAW_DISABLED" value= "3" enum= "DrawMode" >
2017-09-13 04:42:36 +08:00
The state of buttons are disabled.
</constant>
2018-10-07 21:52:07 +08:00
<constant name= "DRAW_HOVER_PRESSED" value= "4" enum= "DrawMode" >
2020-01-14 06:08:42 +08:00
The state of buttons are both hovered and pressed.
2018-10-07 21:52:07 +08:00
</constant>
2017-11-25 06:16:30 +08:00
<constant name= "ACTION_MODE_BUTTON_PRESS" value= "0" enum= "ActionMode" >
2017-09-13 04:42:36 +08:00
Require just a press to consider the button clicked.
</constant>
2017-11-25 06:16:30 +08:00
<constant name= "ACTION_MODE_BUTTON_RELEASE" value= "1" enum= "ActionMode" >
2017-09-13 04:42:36 +08:00
Require a press and a subsequent release before considering the button clicked.
</constant>
</constants>
</class>