My project needs to display a
DocumentWindow to collect some info from the user.
Said window is displayed and
enterModalState() is called on it.
DocumentWindow in turn may need to display a “nested”
DocumentWindow (in the sense that appears in front of it), to collect login credentials.
enterModalState() is called on this window as well. The documentation says that it is possible to have multiple levels of modal components.
When the user closes the frontmost credentials window, the code calls
setVisible (false) on it, in this order.
setVisible (false) is called, an alert “beep” sound is triggered, the one that signals a failed attempt to interact with some other part of the UI when something is modal.
If I comment the
setVisible (false), the sound disappears but the frontmost window remains visible, which is not the desired behaviour.
I have attached a Projucer project that demonstrates this.
The screenshot outlines the result:
The window with the native title bar is the main window (not modal) and has no part in the bug.
The two with the “JUCE” title bar are both in
enterModalState(), with the frontmost being the one that entered last in the modal state. Closing it will “beep”, while closing the one at the first level will not.
If you create more that two nested windows, all those from the second level on will beep when closing. Only the first doesn’t.
How do I avoid the sound to happen for all the nested ones?
Tested on macOS 10.14 with latest JUCE 5.4.5 on develop branch
AlertSoundTest.zip (125.6 KB)