Is there a way to have multiple modal DirectDialog objects, such that only one of them is effectively modal at a time?
That is, such that their modal natures stack, with dialogues being occluded both visually and in terms of input by dialogues above them, and only the the top-most dialogue can be interacted with?
I have a situation in a UI of mine in which I want a modal dialogue to open another modal dialogue. But by default this seems to leave both dialogues interactive (and neither obscured by the “fade-screen”), despite preventing interaction with the non-modal widgets of the UI. It also in this specific case results in the newly-opened dialogue being rendered behind the one from which it was opened.
So, is there a reasonably-feasible way to get the behaviour that I want? Or am I stuck with workarounds like manually hiding the “lower” dialogue, or some such thing…?
Dependent on your setup of the dialogs, you can manually add a background frame that covers the screen and will catch all mouse inputs that go behind the dialog. Something like this:
dlgBackground = DirectFrame(
# we want this backdrop frame to cover everything
Most important are the huge frameSize so it will cover, no matter if the window gets resized afterwards and the state set to “Normal” to actually catch events. Which is probably not the case for the fade-screen.
Simply create it within your dialog as first element or create a helper method to open dialogs with this before and make sure to destroy it once the dialog gets closed.
In case the order is mixed up with the other dialog, you may want to set the sort value of the dialog and the frame manually and try putting them in the popup bin.
As for the styling like frame color, transparency and so on, I’ll leave that up to you. I usually make them black with a 0.25 alpha value.
If you have text entries in the lower dialog, you probably have to un-focus them manually but other than that you should be good.
Ah, that’s a good idea, thank you!
I’ll try it out later and report back, I intend!
I will say that I do think it a pity that this isn’t out-of-the-box behaviour. But ah well.
I’ve tried it, and… you were quite right! Your suggested approach works well indeed!
I did end up using a custom culling-bin instead of “gui-popup”, as the latter turns out to be “unsorted”, thus resulting in explicit sort-orders having no effect. But that was the only deviation, I believe.