Confirmation dialog

I want to make a confirmation dialog for the exit button, the usual “are you sure?” it currently looks like this. the goal is to have the dialog in the middle (this is probably very easy) but the other buttons and the playing field shall not be clickable as long as the dialog is open. is there a easy way to do this? thanks for your help in advance!

Should be doable with layers.



put the new dialog on a different layer, and set the underlying layer to not react to mouse events.

good idea, will try that, thanks :wink:

edit: is there a way to hide a layer? i could save and remove all layer elements and add (to show) them when the button is clicked, but that is kind of cumbersome.



edit2: i can just hide the panel itself. but the layer has a background color (for darkening out the rest) that doesnt vanish… can i change the color or something like that?

Isn’t this exactly what the popup dialog does? For example, the nifty examples, even the intro.xml has a pop-up to ask if you are sure you want to exit.



Or is there some nuance that I’m missing?

Yeah, the popup does something like that. But as far as I know the popup is currently not a modal window, so the screebn behind it would still be accessable. I think, I would have to test this to be sure, haven’t tested this yet with nifty 1.3.

It’s certainly modal as far as nifty is concerned. And it grays the whole background so it might blocking input to any non-nifty stuff, too.

The only purpose of the [xml]<popup …>[/xml] layer is to be modal! :slight_smile:



When you showPopup() a popup layer then everything below that layer should not receive events anymore. This is the only difference between a normal [xml]<layer>[/xml] and a [xml]<popup>[/xml] “layer”. A popup layer is a (most of the time) temporarily visible layer that blocks all events below it.



The “graying” out of the background is just a visual cue used in the nifty-examples project. However, this visual cue is completly up to the user. If you don’t give your popup layer a background color there will be no visual graying out at all. You can give it a half transparent color or a full transparent color or no color at all. Some visual cue would be nice to give your users a hint that there is no interaction possible when the popup layer is being shown tho.

void256 said:
The "graying" out of the background is just a visual cue used in the nifty-examples project. However, this visual cue is completly up to the user. If you don't give your popup layer a background color there will be no visual graying out at all. You can give it a half transparent color or a full transparent color or no color at all. Some visual cue would be nice to give your users a hint that there is no interaction possible when the popup layer is being shown tho.


Totally agree with this. That's why I left it gray in Mythruna for all of my various popups. I only mentioned it to prove that it is in fact covering the whole screen.

Anyway, your answer is a thousand times more authoritative. :)

oh dear, that would have been so much easier :smiley: thanks void for your answer. i’ll implement it with a popup layer later, will edit my results in!

Hallo, I’m unable to find a sample code of a confirmation dialog.

I need only a yes and no button and its handler mapping.

Is there something like that in nifty included or not?

best regards
Matthias