diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2020-07-15 16:31:10 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2020-07-15 16:33:44 +0200 |
commit | 8836c7203b1dd3a4a31db7a769cc656b87c240b4 (patch) | |
tree | f8a037c8b06cf107625e44ab6c5873094c6d3071 /doc | |
parent | f131daf9723d140d1ace991c5acffcba6c08675b (diff) |
Add an example for creating a button in the Button class documentation
This closes https://github.com/godotengine/godot-docs/issues/3798.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/Button.xml | 12 |
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> |