如何获得在右侧触摸条控制中心的项目? [英] How get an item in control center of Touch Bar on the right?

查看:81
本文介绍了如何获得在右侧触摸条控制中心的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该应用TouchSwitcher添加lightscreen和体积项旁项: https://hazeover.com/touchswitcher.html 在这里输入图像描述

The app TouchSwitcher add item beside lightscreen and volume items : https://hazeover.com/touchswitcher.html

是否有触摸栏右侧区域显示项目到控制带材中的溶液

Is there a solution to display an item into the control strip on the right region of touch bar ?

我找不到关于它的官方文档中的任何帮助... 请帮帮我!

I can't find any help in official documentation about it... Please help me !

推荐答案

下面的我用.传递一个和你的选择到功能的标识符.我在做的雨燕采用完全相同的尝试已经导致死机,港口欢迎:).启示 https://github.com/a2/touch-baer .

@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!
  }
}

这篇关于如何获得在右侧触摸条控制中心的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆