0 votes

I think the title is pretty self explanatory, but anyway, i am trying to script a button node called "Quit" which opens a popup that is like a double-check options but I do not know how I would script the button to do this.

in Engine by (298 points)

1 Answer

+1 vote

As an example, create a simple scene with the following 3-node structure:

Node2D (or whatever you want as a root node)
  +- ConfirmationDialog
  +- Button

Add a script to the root node

Wire the button's pressed() signal to the script, containing the following code:

func _on_Button_pressed():
    $ConfirmationDialog.visible = true

That's basically it. When the button is pressed, it's pressed() fires, which calls the _on_Button_pressed() function in the script. That function simply sets the visibility of the dialog to true, which causes it to become visible.

Just season to taste...

by (10,914 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.