A themed button that can contain text and an icon.
Button is the standard themed button. It can contain text and an icon, and it will display them according to the current Theme.
Example: Create a button and connect a method that will be called when the button is pressed:
func _ready():
var button = Button.new()
button.text = "Click me"
button.pressed.connect(_button_pressed)
add_child(button)
func _button_pressed():
print("Hello world!")See also BaseButton which contains common properties and methods associated with this node.
Note: Buttons support multitouch via touch input, allowing multiple buttons to be pressed at the same time. Otherwise, mouse input is used, limiting interaction to one button press at a time.
If set to something other than TextServer.AUTOWRAP_OFF, the text gets wrapped inside the node's bounding rectangle.
Autowrap space trimming flags. See TextServer.BREAK_TRIM_START_EDGE_SPACES and TextServer.BREAK_TRIM_END_EDGE_SPACES for more info.
If true, text that is too large to fit the button is clipped horizontally. If false, the button will always be wide enough to hold the text. The text is not vertically clipped, and the button's height is not affected by this property.
When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect. See also icon_max_width.
Button's icon, if text is present the icon will be placed before the text.
To edit margin and spacing of the icon, use h_separation theme property and content_margin_* properties of the used StyleBoxes.
Specifies if the icon should be aligned horizontally to the left, right, or center of a button. Uses the same HorizontalAlignment constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.
Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.
Specifies if the icon should be aligned vertically to the top, bottom, or center of a button. Uses the same VerticalAlignment constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.