How to remove a custom button in a Dialog Node?

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

In the ConfirmationDialog node there is a function to AddButton() which creates a custom button. However, there is no easy way to remove the button. I have tried looping through the children but there are bugs with this.
Is there an easy way to remove the button added with AddButton()?

:bust_in_silhouette: Reply From: jgodfrey

When you create the button, you should be handed a reference to the new button. As long as you hang on to that, you can remove or hide the button later via any of:

the_button.queue_free()
the_button.visible = false
the_button.hide()

(It looks like you may be using C#, so you’ll need to convert the above gdscript references)

Thank you. The problem is, when I remove the button the horizontal box container that the button was in still saves the place for it. The space just gets bigger and bigger each time I add a button and take it away.

ondesic | 2020-11-18 03:05

I can’t test this ATM, but what happens if you reset the container’s rect_min_size to 0,0 after you remove a button? Does that cause it to resize appropriately?

jgodfrey | 2020-11-18 04:15

This didn’t work. Any other thoughts.

ondesic | 2021-07-03 02:10