summaryrefslogtreecommitdiff
path: root/doc/classes/Button.xml
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-31 13:05:48 +0200
committerGitHub <noreply@github.com>2020-07-31 13:05:48 +0200
commitb1efa0f07f9056737bee39ddd607a00be5f0a2ec (patch)
tree384db203883d599e48832280298434da8583b2c1 /doc/classes/Button.xml
parent932a719f6e80493345ca2374c93d8c50f53b3a9e (diff)
parent8836c7203b1dd3a4a31db7a769cc656b87c240b4 (diff)
Merge pull request #40418 from Calinou/doc-button-code-example
Add an example for creating a button in the Button class documentation
Diffstat (limited to 'doc/classes/Button.xml')
-rw-r--r--doc/classes/Button.xml12
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml
index 675441d842..de05cfcd13 100644
--- a/doc/classes/Button.xml
+++ b/doc/classes/Button.xml
@@ -5,6 +5,18 @@
</brief_description>
<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]
+ 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!")
+ [/codeblock]
+ Buttons (like all Control nodes) can also be created in the editor, but some situations may require creating them from code.
</description>
<tutorials>
</tutorials>