是否有对 macOS Touch Bar 控制条的可编程访问?

Is there programable access to the Control Strip of the macOS Touch Bar?

Control StripmacOS Touch Bar which is always visible in every context and app. While Apple provides full documentation 的静态和全局部分,关于如何使用 API 提供上下文 App Region 在你的 macOS 应用程序中,我找不到任何关于如何将内容添加到控制条的通知。

我能想到很多不错的工具和操作,如果能始终触手可及,那就太好了,所以我想知道我们(开发人员)是否也能推进 Control Strip?是否有任何文档或有人自己弄清楚如何使用 Control Strip 项目?

没有 public API 或支持的方式将项目添加到控制条。

实际上有一个 "private, undocumented" API 可以使用,如果你按照你的问题的相关评论中的 link 可以看到(到 this question). The following GitHub repository 提供了一个简洁的功能示例,将这些作为关键元素突出显示:

DFRElementSetControlStripPresenceForIdentifier(NSString *, BOOL);
DFRSystemModalShowsCloseBoxWhenFrontMost(BOOL);

+[NSTouchBarItem addSystemTrayItem:]
+[NSTouchBar presentSystemModalFunctionBar:systemTrayItemIdentifier:]

但是,我认为目前还没有问题。例如,您在此处添加的按钮在修改控制条按钮时将无法选择(这意味着它无法与其他尝试使用它的应用程序很好地配合使用)。

期待 Apple 为我们实现这一点!