Standard themed Button.
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]
[codeblocks]
[gdscript]
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!")
[/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.
https://godotengine.org/asset-library/asset/515
https://godotengine.org/asset-library/asset/677
Removes all OpenType features.
Returns OpenType feature [code]tag[/code].
Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
Text alignment policy for the button's text, use one of the [enum TextAlign] constants.
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.
When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.
Flat buttons don't display decoration.
Button's icon, if text is present the icon will be placed before the text.
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
The button's text that will be displayed inside the button's area.
Base text writing direction.
Align the text to the left.
Align the text to the center.
Align the text to the right.
[StyleBox] used when the [Button] is disabled.
[StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
[Font] of the [Button]'s text.
Default text [Color] of the [Button].
Text [Color] used when the [Button] is disabled.
Text [Color] used when the [Button] is being hovered.
Text outline [Color] of the [Button].
Text [Color] used when the [Button] is being pressed.
Font size of the [Button]'s text.
[StyleBox] used when the [Button] is being hovered.
The horizontal space between [Button]'s icon and text.
Default [StyleBox] for the [Button].
Size of the [Button]'s text outline.
[StyleBox] used when the [Button] is being pressed.