Use main DocumentWindow from System Tray Icon


#1

How can I get my main DocumentWindow from the overimplemented System Tray Icon? Like I get the instance of JUCEApplication using JUCEApplication::getInstance()?

My situation:
the main doc window is hidden on minimize:

... void minimizeButtonPressed(){ setVisible(false) } ...

I have a pop up menu at tray icon, it contains 2 items:
Show
Exit

exit is implemented using JUCEApplication::getInstance()->systemRequestedQuit() (taken from juce demo app)
and “Show” should be smth like
DocumentWindow::getInstance()->setVisible(true) ??? Of course no, because we can have more than one doc windows… but how?..


#2

either pass a pointer to your DocumentWindow as a parameter to the constructor, or use ChangeListener/Broadcaster classes to create a simple IPC in your application.

If you don’t have ultiple threads, pointers are faster and simpler, if you have threads running definetly look into the ChangeListener/Broadcaster and ActionListener/Broadcaster classes.


#3

Thank you, the pointer works ok for me :slight_smile:


#4

Here has given an idea of atom is very helpful to you.