Button

Inherits: BaseButton < Control < CanvasItem < Node < Object

Inherited By: CheckBox, CheckButton, ColorPickerButton, MenuButton, OptionButton, ToolButton

Botón temático estándar.

Descripción

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:

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.

Tutoriales

Propiedades

TextAlign

align

1

bool

clip_text

false

bool

expand_icon

false

bool

flat

false

Texture

icon

String

text

""

Propiedades del Theme

Color

font_color

Color( 0.88, 0.88, 0.88, 1 )

Color

font_color_disabled

Color( 0.9, 0.9, 0.9, 0.2 )

Color

font_color_focus

Color( 0.94, 0.94, 0.94, 1 )

Color

font_color_hover

Color( 0.94, 0.94, 0.94, 1 )

Color

font_color_pressed

Color( 1, 1, 1, 1 )

int

hseparation

2

Font

font

StyleBox

disabled

StyleBox

focus

StyleBox

hover

StyleBox

normal

StyleBox

pressed

Enumeraciones

enum TextAlign:

  • ALIGN_LEFT = 0 --- Alinea el texto a la izquierda.

  • ALIGN_CENTER = 1 --- Alinea el texto con el centro.

  • ALIGN_RIGHT = 2 --- Alinea el texto a la derecha.

Descripciones de Propiedades

Default

1

Setter

set_text_align(value)

Getter

get_text_align()

Política de alineación de texto para el texto del botón, usa una de las constantes TextAlign.


Default

false

Setter

set_clip_text(value)

Getter

get_clip_text()

Cuando esta propiedad está activada, el texto que es demasiado grande para caber en el botón se recorta, cuando está desactivada el botón siempre será lo suficientemente ancho para contener el texto.


Default

false

Setter

set_expand_icon(value)

Getter

is_expand_icon()

Cuando se habilita, el icono del botón se expandirá o encogerá para adaptarse al tamaño del botón, manteniendo su aspecto.


Default

false

Setter

set_flat(value)

Getter

is_flat()

Los botones planos no muestran decoración.


Setter

set_button_icon(value)

Getter

get_button_icon()

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

To edit margin and spacing of the icon, use hseparation theme property of Button and content_margin_* properties of the used StyleBoxes.


Default

""

Setter

set_text(value)

Getter

get_text()

El texto del botón que se mostrará dentro del área del botón.

Theme Property Descriptions

Default

Color( 0.88, 0.88, 0.88, 1 )

Color del texto predeterminado del Button.


  • Color font_color_disabled

Default

Color( 0.9, 0.9, 0.9, 0.2 )

Color del texto utilizado cuando el Button está desactivado.


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.


Default

Color( 0.94, 0.94, 0.94, 1 )

Color del texto usado cuando el Button tiene encima el cursor.


  • Color font_color_pressed

Default

Color( 1, 1, 1, 1 )

Color del texto utilizado cuando se pulsa el Button.


  • int hseparation

Default

2

El espacio horizontal entre el icono y el texto de Button.


Font del texto del Button.


StyleBox usado cuando el Button está desactivado.


StyleBox que se usa cuando el Button está enfocado. Se muestra sobre el StyleBox actual, por lo que al usar StyleBoxEmpty sólo desactivará el efecto visual de enfoque.


StyleBox que se usa cuando el Button tiene encima el cursor.


StyleBox por defecto para el Button.


StyleBox que se usa cuando se presiona el Button.