Godot Version
4.2
Question
I’m follow the tutorial here which is about having multiple dialog boxes on screen that you can drag around and bring to the front. It’s working fine, my DraggableDialog (PanelContainer) defines a signal:
[Signal]
public delegate void MoveDialogToTopEventHandler(DraggableDialog dialog);
Which is used by my Node that holds the various Panels
public partial class DialogBoxHolder : Control
{
public override void _Ready()
{
var children = GetChildren();
foreach (var child in children)
{
if (child is DraggableDialog)
{
((DraggableDialog)child).MoveDialogToTop += HandleMoveDialogToTop;
}
}
}
private void HandleMoveDialogToTop(DraggableDialog dialog)
{
MoveChild(dialog, GetChildCount() - 1);
}
}
The part I’m not sure about, is how to handle when these dialogs are closed. Inside the DraggableDialog I call QueueFree() to remove the dialog from the scene on close. The Godot docs here say that “While all engine signals connected as events are automatically disconnected when nodes are freed, custom signals aren’t. Meaning that: you will need to manually disconnect (using -=) all the custom signals you connected as C# events (using +=).”
So my question is, how do I disconnect from the custom events in the DialogBoxHolder when the underlying Nodes call QueueFree()?