Closing a PopUp using a button?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KptnFishy

Hello!

I’m looking for a way to close a PopUp using a button.
(the PopUp is used to close the game)
Has anyone got an idea how i can do that?

thanks!

:bust_in_silhouette: Reply From: Pomelo

Your question is too generic. What do you mean by a button? a control node button? in that case use signals. an input keyboard button? then use an _input() function.

How to trigger it is not the issue? maybe you dont know how to “hide it”? in that case if its a control node, a simple .visible = false could do?

Please try to be more specific to see if I (or someone else) can help you

I used a node button to activate the pop-up using popup()

You click the “Quit game” button.
It opens a pop-up with two node buttons.
The code I currently have is:

extends PopUp



Func On_QuitGame_clicked():
Popup() 

Func on_QuitYes_clicked():
Get_tree().quit()

func on_QuitNo_clicked():
Pass #I got no idea what to use to close the pop-up again 

Can I do something else to explain my problem? :slight_smile:

KptnFishy | 2022-07-17 09:27

Then a simple self.visible = false should do the trick!

edit: the same can be done with self.hide(), and you dont even need the self reference I think, but havent used godot for a time now, so dont quite remember

Pomelo | 2022-07-18 13:49

:bust_in_silhouette: Reply From: the_maven

In the Asset Library Projects download either of 2D Platformer Demo.
You’ll the example of what you want and there is script too.