I am working on a MacOS app using Swift/Appkit. I have an NSPanel that is always visible and is a dock replacement. It can receive a drag and drop from any other app, but I don't want it to become the key window and get focus when something is dragged into it. I tried setting canBecomeKey as follows:
override var canBecomeKey: Bool { false }
And this is making sure the window doesn't get focus either when clicked, or when something is dragged into it. But when the mouse is dragged into it, then hovered for a bit, the other app's window from which the drag started is losing focus. Is there any way that I stop this from happening? I don't want the other app's window to lose focus.
Set the styleMask
of the app's panel or window to .nonactivatingPanel
, and the NSApplication
's activationPolicy
to .prohibited