Test if JuceApplication has Focus



Is there a mean to test if your application is the focused one in the OS ?
I want to get that to make only one window from the 10 of my app,
when my app is not focused / on-top of the desktop.

A bit like Photoposh e.g.



Well, you can try this call “isActiveWindow ()”.


Process::isForegroundProcess() might be what you’re looking for?


Oh yes. Thank you;
juce works.


One last question : what is the instance I should use with ?
JUCE_APPLICATION cannot be correct I guess…

[quote]Well, you can try this call “isActiveWindow ()”.[/quote]This is not a clean solution, involving too many tests. Definitely the solution if nothing else available.


Sorry, I don’t understand your question…


Process::isForegroundProcess() :

how do you use it ?
how do you get “Process” ?


it’s a static method, you should be able to call it from anywhere.

static bool Process::isForegroundProcess ( )  throw () [static] 


Of course, thanks.

What would be the best callback to use to test process just befor it loses focus ?


TopLevelWindow::activeWindowStatusChanged () <<