cocoa - 如何在注意力不集中时使 TouchBar 保持事件状态

标签 cocoa appkit macos-sierra xcode8 nstouchbar

我正在尝试创建一个代理应用程序来为现有的闭源应用程序提供触摸栏功能。我可以通过 API 与应用程序进行通信,但我的触摸栏在未聚焦时会消失。

NSTouchBar 文档中它说:

On supported MacBook Pro models, the Touch Bar, above the keyboard, shows instances of the NSTouchBar class from the front-most app.

但是,我想知道是否有办法强制显示哪个触摸栏。我试图不辞职,这在一定程度上起到了作用,但随后我就失去了对应用程序的关注。

func applicationWillResignActive(_ notification: Notification) {
    self.activate(ignoringOtherApps: true) 
}

最佳答案

我想你自己找到了答案。触摸栏旨在仅显示应用程序特定的控件。

来自苹果Human Interface Guidelines :

The Touch Bar […] is a Retina display and input device that provides dynamic interface controls for interacting with content on the main screen. These controls offer quick access to system-level and app-specific functionality based on the current context.

关于cocoa - 如何在注意力不集中时使 TouchBar 保持事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41053746/

相关文章:

macos - 无法 fork : Resource temporarily unavailable issue

java - Payara/GlashFish 不会在 NetBeans 中启动

php - 以编号格式创建许可证 key 问题

swift - NSOutlineView 在低于 10.12 的 Mac OS 版本上崩溃,因为 'stronglyReferencesItems' 默认设置为 'false'

objective-c - 如何在 Mac OS X 上将 CALayer 添加到 NSView

macos - 调整 NSWindow 大小以匹配 Storyboard 中的 View Controller 大小

objective-c - 在 nibless AppKit 项目中将 View 初始化放在哪里?

mysql - 为什么 phpmyadmin 拒绝通过本地主机连接但接受 127.0.0.1?

objective-c - 使用属性字符串突出显示 NSStatusItem

swift - 匹配 AppKit 和 SpriteKit 颜色