Is App foreground app?

Is there any way to tell if my juce app is the foreground / currently focused app. Is there any way to get a notification when this changes?

I believe Process::isForegroundProcess() is what you’re looking for!

I don’t think there’s a system that notifies you if this state changes, though.

1 Like

Just yesterday I searched for a way to raise a window to the front when a file from a different app is dropped into it.
Process::makeForegroundProcess() did the job, thanks! I was only looking in Component…

I’d be careful with that as it’s only supported on Mac (and Linux, maybe?). You might want to try manually bringing up a DocumentWindow to get it working on all platforms.

Thanks for the hint. I have to check, what happens on windows, when I call that. But it’s only a convenience thing, so it’s no big deal, if nothing happens.
DocumentWindow is what I was searching, but I don’t see anything in the API to bring the DocumentWindow into foreground. Do you have a specific method in mind? Maybe I’m just blind…
(I actually searched the whole hierarchy from Component - DocumentWindow - TopLevelWindow - ResizableWindow…)

I’m a bit rusty nowadays, but I think there’s a toFront method or something along those lines.

Yes, it’s a method from Component. I tried that, and it had no effect (on OSX at least), so I reckon it is only meant for inside the juce components hierarchy…

Just went into the code, so it seems to do something on the heavy weight peer, but as I said, had no effect here.