OSX: SystemTrayIconComponent::showDropdownMenu() - need means to bring windows to foreground when app is hidden

On OSX  I am using Process::setDockIconVisible(false) to make my app invisible in the dock and use the recently added SystemTrayIconComponent::showDropdownMenu() call to implement my OSX menu bar app with native OSX cocoa menus.

I want my app invisible in the dock and to the app switcher, like other osx menu bar apps like dropbox, WiFi, Airserver, SwitchResX, Splashtop Streamer etc.  I want to do everyhting from the menu extras dop down menu.

However when one of my menu items gets selected which is designed to display a modal or non-modal window I cannot seem to find a way to make my window or dialog come to the foreground of another app is in the foreground.

How can I make a window or dialog come to the front ?

 I've tried Process::makeForegroundProcess();  but this doesnt work. 

  I use many OSX menu bar apps ( Cocoatech PathFinder, dropbox, Airserver, SwitchResX, Splashtop Streamer ) which do seem to manage to do this. 

I've tried some code suggested in the forum here like: 

File app = File::getSpecialLocation(File::currentApplicationFile);

system(String::formatted(T("open %ls"), (const tchar*)app.getFullPathName()));

 

This is on El Capitan on an iMac . JUCE 4.1

1 Like