Keeping window of another application active while still receiving mouse events from another app's window?

StackOverflow https://stackoverflow.com/questions/2481030

Question

Is there a way to have my app's window receive keyboard and/or mouse events (i.e. user clicking on window's buttons) while still retaining focus to another, unrelated app?

I've tried configuring my window at different levels, including [myWindow setLevel:NSPopUpMenuWindowLevel] to no avail.

Was it helpful?

Solution 2

Found it. Simple, yet elusive.

Use NSPanel and make sure panel style is Non Activating (NSNonactivatingPanelMask) or tick the same option in IB's inspector.

OTHER TIPS

You should be able to handle mouse clicks without ordering your window front by making your views (at least the ones that handle mouse clicks) respond to acceptsFirstMouse: messages by sending NSApp a preventWindowOrdering message and then returning YES.

You should not make your app handle typing without ordering itself front. The user might not realize where their typing is going if the field where it's appearing is obscured by another window.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top