Issue Windows modal state

We have an issue with windows in modal state in our software.
They appear in front all the time, even if you select another application.
We want them to appear in front in our software but not in front of other applications if they are selected.
Any idea how to do that?

Assuming you’re writing a standalone application: do you see the same behaviour in any of the JUCE-vendored projects such as the DemoRunner or Projucer?

Here, on Windows 11, the Projucer’s modal “saving” window doesn’t remain at the top of the Z order when switching to another window.

Similarly, opening the “DialogsDemo” in the DemoRunner, and then clicking the “Plain Alert Window” button opens a new modal window that remains in front of the DemoRunner window, but is reordered behind the active window when switching to another foreground application.

I’d recommend taking a look at how these projects launch modal windows, and then doing something similar in your application.

If you’re writing a plugin, it’s normally best to avoid creating additional whenever possible. Instead, I’d recommend implementing your modal behaviour as an overlay/sheet component that is hidden/shown directly inside your main plugin editor window. This will sidestep any focus issues you may encounter with additional windows, and will also guarantee correct scaling of the overlay on Windows/Linux machines with high-resolution displays.

1 Like

Hello again,

Thanks for the answer @reuk.
We fixed the first issue but now we have another one. On Mac only, when opening a FileChooser from a modal window, the FileChooser appears behind the modal window.
On Windows and Linux there is not the issue. We use Juce 6.1.

Any idea why and how we could fix it?