Is it possible to prevent my app from "Hiding"

Is there any way to prevent my app from hiding, when the user selects the menu item “Hide others” within another app e.g. the Finder?

Maybe anything in “MacOSLib”…

I’m also searching for this. It turns out that an application with LSUIElement can be hidden (quite easily: press command-H while the app is active) and there’s no easy way to show it again (easiest way is to open the app again, meaning searching the bundle).
I think preventing hiding an LSUIElement app should be a minimum.

In the MBS plugin’s documentation, I’m reading we can receive a notification when the app will go hidden, but it’s not mentioned in which of the various notifications classes it would happen nor whether it is cancellable.
Idea, please?

I think what you want is [NSWindow canHide:NO].

The value of this property is YES if the window can hide when its application becomes hidden (during execution of the NSApplication hide: method); otherwise, NO. By default, the value of the property is YES.

You should be able to do this with a simple declare, I’ve just wrote out the below into this forum without testing, but even if it doesn’t work, it should be close.

declare sub NSWindow_canHide lib "AppKit" selector "setCanHide:" ( NSWindowInstance as integer, value as boolean ) // Mac OS X 10.0 + or newer

2 Likes

Thank you, this works perfectly. Much appreciated.
I just changed integer to ptr to pass the window’s handle.

1 Like