Modal juce dialog appears behind modal OSX dialog


I’m replacing the UI of an existing application with juce. There’s an existing OSX-native window which is displayed modally. Previously there was a second native dialog which would display modally on top of this first one. This second native dialog was replaced with a juce dialog, but when it displays, it now goes behind the first (still-native) dialog. Even though it incorrectly hides behind the first dialog, it correctly takes the focus and blocks input to the first dialog. This gives the appearance the app has locked up (since the computer just beeps when you click on the window), unless one knows to move the first dialog aside to expose the second one.

The first OSX-native window is displayed with:
[NSApp beginModalSessionForWindow:theDialog]; // theDialog is the NSPanel being shown

[NSApp stopModal];

While the juce dialog is shown with
juce::DialogWindow::LaunchOptions options;

I tried Component::setAlwaysOnTop() and that had no effect. For cases where I can’t replace the original OSX dialog with juce dialogs, how do I get native dialogs and juce dialogs to layer correctly?

This seems related to Modal dialog issue with third party window, but it’s with an OSX-native window.


There is really not much good things to suggest here. You have two dialogs fighting over modality. By definition you should really only have a single modal window at a time or you’ll get undefined behaviour.