Skip to content

Latest commit

 

History

History
228 lines (134 loc) · 13.1 KB

File metadata and controls

228 lines (134 loc) · 13.1 KB

:github_url: hide

RevisedButton

Inherits: BaseButton

Inherited By: ExpandableButton

Button wich uses RichTextLable to show text.

Description

RevisedButton is more complex themed button than Button. It can contain text and an icon, and it will display them according to the current Theme.

Example of creating a RevisedButton and assigning an action when pressed by code:

.. tabs::

.. code-tab:: gdscript

func _ready() -> void:
    var button = RevisedButton.new()
    button.text = "[i]Click[/i] [b][color=LightGreen]me[/color][/b]"
    button.pressed.connect(self._revised_button_pressed)
    add_child(button)
    button.size = Vector2(125,45)

func _revised_button_pressed():
    print_rich("[color=Violet]Hello world![/color]")

.. code-tab:: csharp

public override void _Ready()
{
    var button = new RevisedButton();
    button.Text = "[i]Click[/i] [b][color=LightGreen]me[/color][/b]";
    button.Size.X = 125;
    button.Size.Y = 45;
    button.Pressed += RevisedButtonPressed;
    AddChild(button);
}

private void RevisedButtonPressed()
{
    GD.Print("Hello world!");
}

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.

Properties

ALIGNMENT_ORDER alignment_order 0
float auto_scrolling_speed 20.0
AutowrapMode autowrap_mode 3
bool expand_icon false
bool flat false
HorizontalAlignment horizontal_text_alignment 1
Texture2D icon
HorizontalAlignment icon_alignment 1
bool is_text_off false
String text "Text"
VerticalAlignment vertical_icon_alignment 0
VerticalAlignment vertical_text_alignment 0

Enumerations

enum ALIGNMENT_ORDER:

ALIGNMENT_ORDER ALIGNMENT_ORDER_VERTICAL_FIRST = 1

There is currently no description for this enum. Please help us by contributing one !

ALIGNMENT_ORDER ALIGNMENT_ORDER_HORIZONTAL_FIRST = 0

There is currently no description for this enum. Please help us by contributing one !


Property Descriptions

ALIGNMENT_ORDER alignment_order = 0

Defines which alignment is more important. See ALIGNMENT_ORDER for more details.

Note: Will be expanded in future versions.

float auto_scrolling_speed = 20.0

  • void set_adaptable_speed( value: float )
  • float get_adaptable_speed( )

Defines speed of text auto scrolling. See AutoScroll for more details.

AutowrapMode autowrap_mode = 3

If set to something other than TextServer.AUTOWRAP_OFF,wich should always be true, the text gets wrapped inside the node's bounding rectangle.

bool expand_icon = false

  • void set_expand_icon( value: bool )
  • bool is_expand_icon( )

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

bool flat = false

  • void set_flat( value: bool )
  • bool is_flat( )

Flat buttons don't display decoration.

HorizontalAlignment horizontal_text_alignment = 1

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

Button's icon, if text is present the icon will be placed before the text unless its horizontal alignment is set to @GlobalScope.HORIZONTAL_ALIGNMENT_RIGHT.

HorizontalAlignment icon_alignment = 1

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.

bool is_text_off = false

  • void set_text_off( value: bool )
  • bool is_text_off( )

When enabled, the text will be hidden.

String text = "Text"

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

VerticalAlignment vertical_icon_alignment = 0

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.

VerticalAlignment vertical_text_alignment = 0

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