Unanswered: Window/Dialog - how do I get toFront behavior when it was added to a Container?
I am trying to get a certain type of behavior.
I have a VerticalLayoutContainer, which has a Widget inside of it.
Under certain circumstances, a Dialog will show, but instead of doing show(), I instead add the Dialog to the VerticalLayoutContainer.
All well and good, until I add multiple Dialogs. When a second dialog is added, it is shown behind the previously added dialog rather than in front of it. Clicking on it does NOT bring it to the front.
How do I get it to appear in front of any other dialogs? toFront() does not do this if I have added the Dialog to a Container rather than simply doing show().
Why does clicking on the Dialog not bring it in front of the others, and how do I get this to happen?
Further, there may be times when I want to bring one (out of possibly many) of those Dialogs to the front programmatically. How can this be done?
I have tried, if it's already onscreen, inserting it to be the first Widget in the Container, but to no avail.
Why are you adding the dialog/window to a container? These are designed to work by calling show, which then tries to add them to the root container, and do the bookkeeping of which item is on top?
These classes aren't intended to work this way. If you have a particular reason for adding them, perhaps you can explain that, and someone can suggest another way of solving _that_ problem, that avoids creating your current one.
Actually, I did come up with a workaround that solves the problem.
It was really a matter of, well, I guess laziness. If the Container was being removed, I wanted all the associated Dialogs to be removed as well.
That, and I guess I'd misinterpreted a response to a question of mine some time ago when I was working with Window and Dialog, and interpreted it as that, at the time, adding to a Container wasn't supported, but that it would be in the future.
Most of the reasons that would make one want to add a window or subclass to a container can be solved by other things, and don't take into account the bookkeeping details that need to be done to make sure window order changes - especially in conjunction with the fact that not everyone will want a parent. A container element can be set on the window to confine it to a particular position, windows can be made non-resizable, non-closeable - these are usually the main pieces.
Consider something like WindowManager.hideAll() if you really want to hide every window, or make an object that groups windows so you can hide sets of them (like GroupingHandlerRegistration does for event HandlerRegistration objects, or FormPanelHelper lets you do for fields in a given container).