Add an example for creating a button in the Button class documentation
This closes https://github.com/godotengine/godot-docs/issues/3798.
This commit is contained in:
parent
f131daf972
commit
8836c7203b
1 changed files with 12 additions and 0 deletions
|
@ -5,6 +5,18 @@
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
Button is the standard themed button. It can contain text and an icon, and will display them according to the current [Theme].
|
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>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
|
|
Loading…
Reference in a new issue