swift - NSAppleEventManager.shared().setEventHandler 窃取焦点

标签 swift macos nsappleeventmanager

在我的应用程序中使用

注册 url 激活时
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(self.handleEvent(_:with:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))

当我的应用程序在 Mac 中窃取用户的焦点时,在我的函数“handleEvent()”激活结束时,我在我的应用程序中收到回调。

我不希望我的应用抢走焦点,因为我在后台运行,而用户甚至不知道他当前的应用为什么会失去焦点。

我怎样才能设置它在不窃取用户注意力的情况下继续运行?

最佳答案

因为我没有得到答案,所以我切换了方法并使用了DistributedNotificationCenter 在 2 个应用程序之间进行通信。

使用此解决方案不会窃取焦点。

关于swift - NSAppleEventManager.shared().setEventHandler 窃取焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52513049/

相关文章:

macos - 管道 & xargs => 顶部

json - Swift 4 中的配置错误

ios - 如何使用json上传图片?

swift - Tableview 原型(prototype)单元高于其他单元

iOS curl -X POST 集成在 swift 中

macos - docker容器更改不保存,osx

c++ - 是否可以通过 clang 和 gcc 支持构建 boost?