Macos 如何在右侧触摸栏的控制中心获取项目?
app TouchSwitcher在光幕和音量项目旁边添加项目: 是否有解决方案将项目显示在触摸栏右侧区域的控制条中 我在官方文件中找不到任何帮助。。。Macos 如何在右侧触摸栏的控制中心获取项目?,macos,cocoa,nstouchbar,macbookpro-touch-bar,Macos,Cocoa,Nstouchbar,Macbookpro Touch Bar,app TouchSwitcher在光幕和音量项目旁边添加项目: 是否有解决方案将项目显示在触摸栏右侧区域的控制条中 我在官方文件中找不到任何帮助。。。 请帮帮我 在反编译之后,我在一个名为DFRFoundation的框架中发现了一些API,该框架位于/System/Library/PrivateFrameworks下,以及一个相关的方法dfrelationSetControlStripPresenceforIdentifier。我发现很难进一步了解,所以我在这里回答这个问题只是为了让您知道这
请帮帮我 在反编译之后,我在一个名为DFRFoundation的框架中发现了一些API,该框架位于/System/Library/PrivateFrameworks下,以及一个相关的方法
dfrelationSetControlStripPresenceforIdentifier
。我发现很难进一步了解,所以我在这里回答这个问题只是为了让您知道这个API是在一个私有框架中。希望有一天有人能揭发这些秘密。以下是我的建议。将NSView
和您选择的标识符传递给controlStrippify()
函数。我尝试使用Swift做完全相同的事情,结果导致崩溃,欢迎:)。灵感来自
NSTouchBar文档中:“在触摸栏的右侧,系统提供始终可用的控制条。通过控制条,用户可以访问显示器亮度、音量、Siri等标准控件。应用程序的控制条显示在控制条的左侧。(用户可以选择隐藏控制条,使最前面的应用程序具有整个触摸栏的宽度。)这意味着您的应用程序的条形图总是显示在左侧,而右侧的项目则不可能出现。您甚至无法访问控制条条形图项目。当最前面的出现时,
dfrsystemodalshowscloseboxwhen做了什么?无论提供的bool值或是否存在右行,它似乎都不会产生任何影响@redtection,code更新到不要再使用那个了。
@import Cocoa;
@import Foundation;
// See: https://github.com/a2/touch-baer
extern void DFRElementSetControlStripPresenceForIdentifier(NSString *string, BOOL enabled);
@interface NSTouchBarItem ()
+ (void)addSystemTrayItem:(NSTouchBarItem *)item;
@end
@interface NSTouchBar ()
+ (void)presentSystemModalFunctionBar:(NSTouchBar *)touchBar systemTrayItemIdentifier:(NSString *)identifier;
@end
void controlStrippify(NSView *view, NSString *identifier) {
if (@available(macOS 10.12.2, *)) {
NSCustomTouchBarItem *touchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
touchBarItem.view = view;
[NSTouchBarItem addSystemTrayItem:touchBarItem];
DFRElementSetControlStripPresenceForIdentifier(identifier, YES);
} else {
// Fail!
}
}