[英]NSStatusItem app focus
How can my menubar application achieve the same behaviours as 1Password or Dropbox: 我的菜单栏应用程序如何实现与1Password或Dropbox相同的行为:
I figured out how mouse over works in the Dropbox popover table view by using an NSTrackingArea with the options MouseEnteredAndExited, AssumeInside, and ActiveAlways. 我通过使用带有选项MouseEnteredAndExited,AssumeInside和ActiveAlways的NSTrackingArea来了解鼠标在Dropbox弹出窗口视图中是如何工作的。
I am trying to get the same behaviour to work in an NSPopover that opens from an NSStatusItem. 我试图在从NSStatusItem打开的NSPopover中使用相同的行为。
I found a workaround for now. 我现在找到了解决方法。 I am able to get the same behaviour by using non-activating NSPanel with a window level kCGPopUpMenuWindowLevelKey
and I had to override canBecomeKeyWindow
to return true. 通过使用具有窗口级别kCGPopUpMenuWindowLevelKey
非激活NSPanel,我能够获得相同的行为,并且我必须覆盖canBecomeKeyWindow
以返回true。
Unfortunately I haven't found a way yet to get a NSPopover to behave this way since it's not a subclass of NSWindow. 不幸的是,我还没有找到一种方法让NSPopover以这种方式运行,因为它不是NSWindow的子类。
要设置您所描述的行为类型,请使用:
yourPopover.behavior = .transient
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.