Skip to content

Commit

Permalink
Merge pull request #40418 from Calinou/doc-button-code-example
Browse files Browse the repository at this point in the history
Add an example for creating a button in the Button class documentation
  • Loading branch information
akien-mga authored Jul 31, 2020
2 parents 932a719 + 8836c72 commit b1efa0f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/classes/Button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit b1efa0f

Please sign in to comment.