Closing menus brings the window containing it to front


#1

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.


#2

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.


#3

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

Thanks!


#4

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


#5

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…


#6

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()…


#7

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


#8

from a TreeViewItem…


#9