You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you add custom buttons to any popup Dialogs, upon deleting them, the remaining buttons do not recenter.
Steps to reproduce
Create a project with a button and any Dialog node that you can use "add_button()" on.
In the button put code that opens the dialog and adds a custom button through "add_button()".
Next close the Dialog node and make the second time the DIalog opens delete the custom button.
The resulting Dialog will have all remaining buttons off-centered.
Minimal reproduction project
In this reproduction project press the button once and you get this:
Close the Dialog and press the button again. This time it will add a new button. All is well:
close the dialog and push the Button again. This time it will delete the custom button. Notice how even though the custom button is gone, things are off-centered:
Close dialog and press the button again. Now the code adds a custom button back. Again, everything is off centered:
Happens because AcceptDialog::add_button adds spacers (here Controls extending horizontally) around buttons so the layout in HBoxContainer with the buttons is like: spacer-button-...-(spacer-button)-...-spacer. Removing a button makes spacers adjacent, hence the issue.
Adding AcceptDialog::remove_button which would handle removing spacers accordingly should solve this issue. I'll open a PR.
@ondesic As a workaround for now you'd need to remove them manually. For example adding such extension method should do the thing (C#):
public static class AcceptDialogExtensions
{
public static void RemoveButton(this AcceptDialog acceptDialog, Button button)
{
if (button == null)
{
return;
}
HBoxContainer hbc = acceptDialog.GetOk().GetParent<HBoxContainer>();
if (button.GetParent() != hbc)
{
return;
}
Node rightSpacer = hbc.GetChild(button.GetIndex() + 1);
if (rightSpacer != null)
{
hbc.RemoveChild(rightSpacer);
rightSpacer.QueueFree();
}
hbc.RemoveChild(button);
if (button.IsConnected("pressed", acceptDialog, "_custom_action"))
{
button.Disconnect("pressed", acceptDialog, "_custom_action");
}
}
}
and here's your button pressed handler modified to use it:
Godot version
3.3.2 official
System information
Windows 10
Issue description
If you add custom buttons to any popup Dialogs, upon deleting them, the remaining buttons do not recenter.
Steps to reproduce
Create a project with a button and any Dialog node that you can use "add_button()" on.
In the button put code that opens the dialog and adds a custom button through "add_button()".
Next close the Dialog node and make the second time the DIalog opens delete the custom button.
The resulting Dialog will have all remaining buttons off-centered.
Minimal reproduction project
In this reproduction project press the button once and you get this:




Close the Dialog and press the button again. This time it will add a new button. All is well:
close the dialog and push the Button again. This time it will delete the custom button. Notice how even though the custom button is gone, things are off-centered:
Close dialog and press the button again. Now the code adds a custom button back. Again, everything is off centered:
Here is the project (code is in C#):
Dialog.zip
The text was updated successfully, but these errors were encountered: