2017-09-12 22:42:36 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2020-02-01 02:03:48 +01:00
<class name= "Button" inherits= "BaseButton" version= "4.0" >
2017-09-12 22:42:36 +02:00
<brief_description >
Standard themed Button.
</brief_description>
<description >
Button is the standard themed button. It can contain text and an icon, and will display them according to the current [Theme].
2020-07-15 16:31:10 +02:00
[b]Example of creating a button and assigning an action when pressed by code:[/b]
2020-07-31 16:07:26 +02:00
[codeblocks]
[gdscript]
2020-07-15 16:31:10 +02:00
func _ready():
var button = Button.new()
button.text = "Click me"
button.connect("pressed", self, "_button_pressed")
add_child(button)
func _button_pressed():
print("Hello world!")
2020-07-31 16:07:26 +02:00
[/gdscript]
[csharp]
public override void _Ready()
{
var button = new Button();
button.Text = "Click me";
button.Connect("pressed", this, nameof(ButtonPressed));
AddChild(button);
}
private void ButtonPressed()
{
GD.Print("Hello world!");
}
[/csharp]
[/codeblocks]
2020-07-15 16:31:10 +02:00
Buttons (like all Control nodes) can also be created in the editor, but some situations may require creating them from code.
2020-09-23 23:34:28 +02:00
See also [BaseButton] which contains common properties and methods associated with this node.
2021-02-21 00:23:08 +01:00
[b]Note:[/b] Buttons do not interpret touch input and therefore don't support multitouch, since mouse emulation can only press one button at a given time. Use [TouchScreenButton] for buttons that trigger gameplay movement or actions, as [TouchScreenButton] supports multitouch.
2017-09-12 22:42:36 +02:00
</description>
<tutorials >
2020-10-01 10:34:47 +02:00
<link title= "2D Dodge The Creeps Demo" > https://godotengine.org/asset-library/asset/515</link>
<link title= "OS Test Demo" > https://godotengine.org/asset-library/asset/677</link>
2017-09-12 22:42:36 +02:00
</tutorials>
<methods >
2020-08-12 13:49:10 +02:00
<method name= "clear_opentype_features" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
2020-08-12 13:49:10 +02:00
<description >
Removes all OpenType features.
</description>
</method>
<method name= "get_opentype_feature" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
<argument index= "0" name= "tag" type= "String" />
2020-08-12 13:49:10 +02:00
<description >
Returns OpenType feature [code]tag[/code].
</description>
</method>
<method name= "set_opentype_feature" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
<argument index= "0" name= "tag" type= "String" />
<argument index= "1" name= "value" type= "int" />
2020-08-12 13:49:10 +02:00
<description >
Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
</description>
</method>
2017-09-12 22:42:36 +02:00
</methods>
<members >
2019-06-29 12:38:01 +02:00
<member name= "align" type= "int" setter= "set_text_align" getter= "get_text_align" enum= "Button.TextAlign" default= "1" >
2019-12-06 23:09:20 +01:00
Text alignment policy for the button's text, use one of the [enum TextAlign] constants.
2017-09-12 22:42:36 +02:00
</member>
2019-06-29 12:38:01 +02:00
<member name= "clip_text" type= "bool" setter= "set_clip_text" getter= "get_clip_text" default= "false" >
2019-08-29 04:12:22 +02:00
When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.
2017-09-12 22:42:36 +02:00
</member>
2019-08-20 18:41:14 +02:00
<member name= "expand_icon" type= "bool" setter= "set_expand_icon" getter= "is_expand_icon" default= "false" >
When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.
</member>
2019-06-29 12:38:01 +02:00
<member name= "flat" type= "bool" setter= "set_flat" getter= "is_flat" default= "false" >
2017-09-12 22:42:36 +02:00
Flat buttons don't display decoration.
</member>
2020-02-12 09:59:06 +01:00
<member name= "icon" type= "Texture2D" setter= "set_button_icon" getter= "get_button_icon" >
2017-09-12 22:42:36 +02:00
Button's icon, if text is present the icon will be placed before the text.
2021-11-18 15:03:03 +01:00
To edit margin and spacing of the icon, use [theme_item hseparation] theme property and [code]content_margin_*[/code] properties of the used [StyleBox]es.
2017-09-12 22:42:36 +02:00
</member>
2019-10-25 05:29:10 +02:00
<member name= "icon_align" type= "int" setter= "set_icon_align" getter= "get_icon_align" enum= "Button.TextAlign" default= "0" >
Specifies if the icon should be aligned to the left, right, or center of a button. Uses the same [enum TextAlign] constants as the text alignment. If centered, text will draw on top of the icon.
</member>
2020-08-12 13:49:10 +02:00
<member name= "language" type= "String" setter= "set_language" getter= "get_language" default= """" >
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
</member>
2019-06-29 12:38:01 +02:00
<member name= "text" type= "String" setter= "set_text" getter= "get_text" default= """" >
2017-09-12 22:42:36 +02:00
The button's text that will be displayed inside the button's area.
</member>
2020-08-12 13:49:10 +02:00
<member name= "text_direction" type= "int" setter= "set_text_direction" getter= "get_text_direction" enum= "Control.TextDirection" default= "0" >
Base text writing direction.
</member>
2017-09-12 22:42:36 +02:00
</members>
<constants >
2017-11-24 23:16:30 +01:00
<constant name= "ALIGN_LEFT" value= "0" enum= "TextAlign" >
2017-09-12 22:42:36 +02:00
Align the text to the left.
</constant>
2017-11-24 23:16:30 +01:00
<constant name= "ALIGN_CENTER" value= "1" enum= "TextAlign" >
2017-09-12 22:42:36 +02:00
Align the text to the center.
</constant>
2017-11-24 23:16:30 +01:00
<constant name= "ALIGN_RIGHT" value= "2" enum= "TextAlign" >
2017-09-12 22:42:36 +02:00
Align the text to the right.
</constant>
</constants>
<theme_items >
2021-08-04 18:54:41 +02:00
<theme_item name= "disabled" data_type= "style" type= "StyleBox" >
2020-01-27 02:15:37 +01:00
[StyleBox] used when the [Button] is disabled.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "focus" data_type= "style" type= "StyleBox" >
2020-01-27 02:15:37 +01:00
[StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font" data_type= "font" type= "Font" >
2020-01-27 02:15:37 +01:00
[Font] of the [Button]'s text.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_color" data_type= "color" type= "Color" default= "Color(0.88, 0.88, 0.88, 1)" >
2020-01-27 02:15:37 +01:00
Default text [Color] of the [Button].
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_disabled_color" data_type= "color" type= "Color" default= "Color(0.9, 0.9, 0.9, 0.2)" >
2020-01-27 02:15:37 +01:00
Text [Color] used when the [Button] is disabled.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-10-26 16:28:12 +02:00
<theme_item name= "font_focus_color" data_type= "color" type= "Color" default= "Color(0.94, 0.94, 0.94, 1)" >
Text [Color] used when the [Button] is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_hover_color" data_type= "color" type= "Color" default= "Color(0.94, 0.94, 0.94, 1)" >
2020-01-27 02:15:37 +01:00
Text [Color] used when the [Button] is being hovered.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_hover_pressed_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2021-01-27 08:22:23 +01:00
Text [Color] used when the [Button] is being hovered and pressed.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_outline_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-12-25 22:45:28 +01:00
The tint of text outline of the [Button].
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_pressed_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-12-08 14:11:45 +01:00
Text [Color] used when the [Button] is being pressed.
2020-08-12 13:49:10 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "font_size" data_type= "font_size" type= "int" >
2020-08-12 13:49:10 +02:00
Font size of the [Button]'s text.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "hover" data_type= "style" type= "StyleBox" >
2020-01-27 02:15:37 +01:00
[StyleBox] used when the [Button] is being hovered.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "hseparation" data_type= "constant" type= "int" default= "2" >
2020-01-27 02:15:37 +01:00
The horizontal space between [Button]'s icon and text.
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "icon_disabled_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-05-08 08:03:52 +02:00
Icon modulate [Color] used when the [Button] is disabled.
</theme_item>
2021-10-26 16:28:12 +02:00
<theme_item name= "icon_focus_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
Icon modulate [Color] used when the [Button] is focused. Only replaces the normal modulate color of the button. Disabled, hovered, and pressed states take precedence over this color.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "icon_hover_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-05-08 08:03:52 +02:00
Icon modulate [Color] used when the [Button] is being hovered.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "icon_hover_pressed_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-05-08 08:03:52 +02:00
Icon modulate [Color] used when the [Button] is being hovered and pressed.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "icon_normal_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2021-01-27 08:22:23 +01:00
Default icon modulate [Color] of the [Button].
2020-05-08 08:03:52 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "icon_pressed_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-05-08 08:03:52 +02:00
Icon modulate [Color] used when the [Button] is being pressed.
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "normal" data_type= "style" type= "StyleBox" >
2020-01-27 02:15:37 +01:00
Default [StyleBox] for the [Button].
2017-09-12 22:42:36 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "outline_size" data_type= "constant" type= "int" default= "0" >
2020-12-25 22:45:28 +01:00
The size of the text outline.
2020-08-12 13:49:10 +02:00
</theme_item>
2021-08-04 18:54:41 +02:00
<theme_item name= "pressed" data_type= "style" type= "StyleBox" >
2020-01-27 02:15:37 +01:00
[StyleBox] used when the [Button] is being pressed.
2017-09-12 22:42:36 +02:00
</theme_item>
</theme_items>
</class>