How do I remove the exit button from a WindowDialog?

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

I’m using a WindowDialog to display story event text and options to the player, and I don’t want the window to have an exit button in the upper right. The player has to select an option, they can’t just dismiss the dialog.

Is there a way to remove the exit button so I can have full control over when the WindowDialog is allowed to close?

:bust_in_silhouette: Reply From: jgodfrey

Looks like you can get a reference to the close button and then hide or remove it. So, something like this…

var btn = $WindowDialog.get_close_button()
btn.visible = false  // hide the button, or...
btn.queue_free()     // ...remove it all together

Works when I use .hide() on the retrieved close button.

Attempting to free it causes a crash.

steely | 2020-01-31 01:54

Hmmm… I tried them both before posting and they seemed to work ok here (in 3.2). Anyway, glad hiding it works.

jgodfrey | 2020-01-31 03:16

The engine expects you not to free internal nodes, so hiding them is a better solution indeed.

Calinou | 2020-02-02 16:51

Ya using queue_free() crashes the program. At least when you hide a button it doesn’t work.

toivocat | 2021-12-24 20:46