:github_url: hide
Inherits: BaseButton
Inherited By: ExpandableButton
Button wich uses RichTextLable to show text.
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.
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 !
ALIGNMENT_ORDER alignment_order = 0
- void set_alignment_order( value: ALIGNMENT_ORDER )
- ALIGNMENT_ORDER get_alignment_order( )
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
Defines speed of text auto scrolling. See AutoScroll for more details.
AutowrapMode autowrap_mode = 3
- void set_text_autowrap( value: AutowrapMode )
- AutowrapMode get_text_autowrap( )
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
When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.
bool flat = false
Flat buttons don't display decoration.
HorizontalAlignment horizontal_text_alignment = 1
- void set_text_alignment( value: HorizontalAlignment )
- HorizontalAlignment get_text_alignment( )
Text alignment policy for the button's text, use one of the HorizontalAlignment constants.
Texture2D icon
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
- void set_icon_alignment( value: HorizontalAlignment )
- HorizontalAlignment get_icon_alignment( )
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
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
- void set_vertical_icon_alignment( value: VerticalAlignment )
- VerticalAlignment get_vertical_icon_alignment( )
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
- void set_v_text_alignment( value: VerticalAlignment )
- VerticalAlignment get_v_text_alignment( )
Text alignment policy for the button's text, use one of the VerticalAlignment constants.