This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes


I created a scene to use it as a custom Popup dialog.
Its structure is:


I would like to know (from the root scene that will load this custom scene) when and which of the buttons was clicked. How do I approach this, please?


in Engine by (89 points)

1 Answer

+1 vote
Best answer

When you have to communicate with the parent scene, a nice approach is to use signals.
So you can have a script in your Panel that basically exposes signals this way (partial code):

signal choice1_selected
signal choice2_selected

func _on_Button1_pressed():

func _on_Button2_pressed():

Then in the scene that contains this panel, you can listen to those signals by connecting a function to them.

You could connect directly to the buttons, but it's as wrong as accessing private members of a class IMO, and it would break if you change or rename the buttons later.

by (29,510 points)
selected by

Just for possible future searches:
In the scene that contains the panel:

get_node("Panel").connect("choice1_selected", self, "method_to_call")

And yes Zylann, I asked this question because I thought it was a bit awful to connect the buttons directly.

Thank you very much! :)

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 Frequently asked questions and 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 [email protected] with your username.