开发者

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

开发者 https://www.devze.com 2022-12-23 18:53 出处:网络
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?

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 lev开发者_Python百科els, including [myWindow setLevel:NSPopUpMenuWindowLevel] to no avail.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号