Closing menus brings the window containing it to front


I have a main window with a popup menu whose items open new windows. When these new windows open (to the front) and the popup menu goes away, the main windows comes to front, hiding the new window just opened.

It seems the closing of the menu causes the window to go to front. If I open a normal drop-down menu and, without closing it, I click another window (even non-juce windows) that window goes to front briefly, the juce window lose focus, closes the menu and comes to front…

This behavior happens only on Mac (ppc and intel) with non-modal windows.


yes - when the menu goes away, it gives focus back to the window that launched it, and on the mac that’ll bring it to the front… I guess that’s not ideal - I’ll have a think about a better way of doing it.


What could be a quick work-around? A way to open the new window only after the menu is closed?



Yes - you could just fire off a message and open the window when the message arrives. Using Component::postCommandMessage would be the easiest way.


Actually, I’m just looking at this and can’t get it to happen - surely it’s the same thing as the juce demo’s “show source code window” menu option? That opens a new window but works fine…


Could be the difference against the demo is that I use PopupMenu::menuAt()? In the same method itemClicked() I was calling menuAt() and immediately after opening the new window.
I resolved deferring the window opening with postCommandMessage()…


itemClicked? What’s the component you’re getting that from? A listbox?


from a TreeViewItem…