Hello,
I want to add a Confirm Box Yes/No when a button is pressed. How to set it up in Tree and Codes? Thanks.
eg.
-Control #script
--Button #pressed() signal "do something" to Control
How to use ConfirmationDialog?
You would use a Popup to show the modal. Inside you can use a Label for text and then a HBoxContainer to hold the two buttons.
Popup
VBoxContainer
Label
HBoxContainer
Button
Button
- Edited
That was how I manually setup but then I found out about ConfirmationDialog / AcceptDialog. I couldn't find example of how to use it.
Im on GD4 btw
- Edited
If I recall correctly, I encountered the same problem. I couldn't figure out how to use those nodes.
I chose this alternative (the number of Buttons depends on the use-case):
WindowDialog
.. Panel
.. .. Label
.. .. Button
.. .. Button
Ok so I tested it again and now it works:
-Add the ConfirmationDialog node
-Set flag to invisible
-Fire its Confirm/Cancel signals to script to do whatever
-Add a normal button
-Then signal the button to turn ConfirmationDialog to visible when pressed
Example Tree:
-Control #Script
--ConfirmationDialog #Signal
--Button #Signal
Basically the "wiring" is the same but no need to manually adding the yes/no buttons. (which is what I originally wanted )