summaryrefslogtreecommitdiff
path: root/doc/classes/Button.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/Button.xml')
-rw-r--r--doc/classes/Button.xml103
1 files changed, 90 insertions, 13 deletions
diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml
index de05cfcd13..dfbd6c0680 100644
--- a/doc/classes/Button.xml
+++ b/doc/classes/Button.xml
@@ -6,7 +6,8 @@
<description>
Button is the standard themed button. It can contain text and an icon, and will display them according to the current [Theme].
[b]Example of creating a button and assigning an action when pressed by code:[/b]
- [codeblock]
+ [codeblocks]
+ [gdscript]
func _ready():
var button = Button.new()
button.text = "Click me"
@@ -15,12 +16,52 @@
func _button_pressed():
print("Hello world!")
- [/codeblock]
+ [/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]
Buttons (like all Control nodes) can also be created in the editor, but some situations may require creating them from code.
+ See also [BaseButton] which contains common properties and methods associated with this node.
+ [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.
</description>
<tutorials>
+ <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>
</tutorials>
<methods>
+ <method name="clear_opentype_features">
+ <return type="void" />
+ <description>
+ Removes all OpenType features.
+ </description>
+ </method>
+ <method name="get_opentype_feature" qualifiers="const">
+ <return type="int" />
+ <argument index="0" name="tag" type="String" />
+ <description>
+ Returns OpenType feature [code]tag[/code].
+ </description>
+ </method>
+ <method name="set_opentype_feature">
+ <return type="void" />
+ <argument index="0" name="tag" type="String" />
+ <argument index="1" name="value" type="int" />
+ <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>
</methods>
<members>
<member name="align" type="int" setter="set_text_align" getter="get_text_align" enum="Button.TextAlign" default="1">
@@ -38,9 +79,18 @@
<member name="icon" type="Texture2D" setter="set_button_icon" getter="get_button_icon">
Button's icon, if text is present the icon will be placed before the text.
</member>
+ <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>
+ <member name="language" type="String" setter="set_language" getter="get_language" default="&quot;&quot;">
+ Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
+ </member>
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
The button's text that will be displayed inside the button's area.
</member>
+ <member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" enum="Control.TextDirection" default="0">
+ Base text writing direction.
+ </member>
</members>
<constants>
<constant name="ALIGN_LEFT" value="0" enum="TextAlign">
@@ -54,37 +104,64 @@
</constant>
</constants>
<theme_items>
- <theme_item name="disabled" type="StyleBox">
+ <theme_item name="disabled" data_type="style" type="StyleBox">
[StyleBox] used when the [Button] is disabled.
</theme_item>
- <theme_item name="focus" type="StyleBox">
+ <theme_item name="focus" data_type="style" type="StyleBox">
[StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
</theme_item>
- <theme_item name="font" type="Font">
+ <theme_item name="font" data_type="font" type="Font">
[Font] of the [Button]'s text.
</theme_item>
- <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )">
+ <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Default text [Color] of the [Button].
</theme_item>
- <theme_item name="font_color_disabled" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )">
+ <theme_item name="font_disabled_color" data_type="color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)">
Text [Color] used when the [Button] is disabled.
</theme_item>
- <theme_item name="font_color_hover" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
+ <theme_item name="font_hover_color" data_type="color" type="Color" default="Color(0.94, 0.94, 0.94, 1)">
Text [Color] used when the [Button] is being hovered.
</theme_item>
- <theme_item name="font_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
+ <theme_item name="font_hover_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ Text [Color] used when the [Button] is being hovered and pressed.
+ </theme_item>
+ <theme_item name="font_outline_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ The tint of text outline of the [Button].
+ </theme_item>
+ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [Button] is being pressed.
</theme_item>
- <theme_item name="hover" type="StyleBox">
+ <theme_item name="font_size" data_type="font_size" type="int">
+ Font size of the [Button]'s text.
+ </theme_item>
+ <theme_item name="hover" data_type="style" type="StyleBox">
[StyleBox] used when the [Button] is being hovered.
</theme_item>
- <theme_item name="hseparation" type="int" default="2">
+ <theme_item name="hseparation" data_type="constant" type="int" default="2">
The horizontal space between [Button]'s icon and text.
</theme_item>
- <theme_item name="normal" type="StyleBox">
+ <theme_item name="icon_disabled_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ Icon modulate [Color] used when the [Button] is disabled.
+ </theme_item>
+ <theme_item name="icon_hover_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ Icon modulate [Color] used when the [Button] is being hovered.
+ </theme_item>
+ <theme_item name="icon_hover_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ Icon modulate [Color] used when the [Button] is being hovered and pressed.
+ </theme_item>
+ <theme_item name="icon_normal_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ Default icon modulate [Color] of the [Button].
+ </theme_item>
+ <theme_item name="icon_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ Icon modulate [Color] used when the [Button] is being pressed.
+ </theme_item>
+ <theme_item name="normal" data_type="style" type="StyleBox">
Default [StyleBox] for the [Button].
</theme_item>
- <theme_item name="pressed" type="StyleBox">
+ <theme_item name="outline_size" data_type="constant" type="int" default="0">
+ The size of the text outline.
+ </theme_item>
+ <theme_item name="pressed" data_type="style" type="StyleBox">
[StyleBox] used when the [Button] is being pressed.
</theme_item>
</theme_items>