Accept mouse clicks without activating the application?

I am working on a utility that manages other running applications. At a certain input event, my application displays a window, the user can select some operation from the window, the window disappears and control returns to the previous application. My problem is that clicking in the window of my applications activates my application, thus removing focus from the window of previous applications. I can reactivate the previous application when my window closes, but Id rather keep the original application all the time. Is it possible?

+7
source share
2 answers

It's quite simple, just make your window an instance of NSPanel (a subclass of NSWindow ) and set it to not activate in Xcode / IB (or create it programmatically, with NSNonactivatingPanelMask in a style mask).

enter image description here

+5
source

One idea would be that while your application is running, try writing the track of the active window to the system. After you activate the application and press the command button, restore the previous active window. This is just an idea, I don’t know how to do it on Mac.

0
source

All Articles