Tip : Make a window float above application but not system

I needed this myself, so here’s a little helper…

Typically when you use setAlwaysOnTop on mac in a Juce App, it floats it above all windows in the system… Got some complaints about that(user’s wanted the window to disappear when the app doesn’t have focus)…


MacHelpers is the namespace…
and then in a .mm file

void MacHelpers::makeWindowFloatingPanel(Component *aComponent)
	ComponentPeer *componentPeer=aComponent->getPeer();
	NSView* const peer = (NSView*) (componentPeer->getNativeHandle());
	NSWindow *window=[peer window];
	[window setHidesOnDeactivate:YES];

Interesting tip, thanks!

Nice… is there a similar way to do this on Win? (sorry, I know this is the Mac forum…)

Thanks a lot for this! I was having a ton of trouble trying to get this behavior for a window in a Reaper extension plugin. 

We emulate this behaviour with the Tracktion plugin windows by using a timer and checking Process::isForegroundProcess. If the state changes you can hide/show the relevant windows.

1 Like

It’s a horrible hack, but it’s better than no hack :wink: