summaryrefslogtreecommitdiff
path: root/doc/classes/Button.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/Button.xml')
-rw-r--r--doc/classes/Button.xml23
1 files changed, 21 insertions, 2 deletions
diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml
index de05cfcd13..df47fa8bec 100644
--- a/doc/classes/Button.xml
+++ b/doc/classes/Button.xml
@@ -6,7 +6,8 @@
<description>
Button is the standard themed button. It can contain text and an icon, and will display them according to the current [Theme].
[b]Example of creating a button and assigning an action when pressed by code:[/b]
- [codeblock]
+ [codeblocks]
+ [gdscript]
func _ready():
var button = Button.new()
button.text = "Click me"
@@ -15,10 +16,28 @@
func _button_pressed():
print("Hello world!")
- [/codeblock]
+ [/gdscript]
+ [csharp]
+ public override void _Ready()
+ {
+ var button = new Button();
+ button.Text = "Click me";
+ button.Connect("pressed", this, nameof(ButtonPressed));
+ AddChild(button);
+ }
+
+ private void ButtonPressed()
+ {
+ GD.Print("Hello world!");
+ }
+ [/csharp]
+ [/codeblocks]
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.
</description>
<tutorials>
+ <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/515</link>
+ <link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link>
</tutorials>
<methods>
</methods>