Button

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. Example of creating a button and assigning an action when pressed by code:

More...

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
TextAlign
enum TextAlign

Functions

getButtonIcon
Ref!Texture getButtonIcon()
getClipText
bool getClipText()
getText
String getText()
getTextAlign
Button.TextAlign getTextAlign()
isExpandIcon
bool isExpandIcon()
isFlat
bool isFlat()
opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(Button other)
opEquals
bool opEquals(typeof(null) n)
setButtonIcon
void setButtonIcon(Texture texture)
setClipText
void setClipText(bool enabled)
setExpandIcon
void setExpandIcon(bool arg0)
setFlat
void setFlat(bool enabled)
setText
void setText(String text)
setTextAlign
void setTextAlign(long _align)
toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

_align
Button.TextAlign _align [@property getter]
long _align [@property setter]

Text alignment policy for the button's text, use one of the textalign constants.

clipText
bool clipText [@property getter]
bool clipText [@property setter]

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.

expandIcon
bool expandIcon [@property getter]
bool expandIcon [@property setter]

When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.

flat
bool flat [@property getter]
bool flat [@property setter]

Flat buttons don't display decoration.

icon
Texture icon [@property getter]
Texture icon [@property setter]

Button's icon, if text is present the icon will be placed before the text.

text
String text [@property getter]
String text [@property setter]

The button's text that will be displayed inside the button's area.

Static functions

_new
Button _new()

Construct a new instance of Button. Note: use memnew!Button instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

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!")

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. Note: 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.

Meta