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

前端 未结 2 506
渐次进展
渐次进展 2021-01-02 01:28

The Control Strip is the static and global part of the macOS Touch Bar which is always visible in every context and app. While Apple provides full documenta

相关标签:
2条回答
  • 2021-01-02 02:01

    There is in fact a "private, undocumented" API that can be used, as you can see if you follow the link in the Related comment on your question (to this question). The following GitHub repository provides a succinct, functional example, highlighting these as the key elements:

    DFRElementSetControlStripPresenceForIdentifier(NSString *, BOOL);
    DFRSystemModalShowsCloseBoxWhenFrontMost(BOOL);
    
    +[NSTouchBarItem addSystemTrayItem:]
    +[NSTouchBar presentSystemModalFunctionBar:systemTrayItemIdentifier:]
    

    However, I don't think it's problem-free at this point. For instance, buttons you add there won't be selectable when modifying the control strip buttons (which means it won't play well with other apps that try to use it as well).

    Looking forward to Apple making this legit for us!

    0 讨论(0)
  • 2021-01-02 02:04

    There is no public API or supported way to add items to the control strip.

    0 讨论(0)
提交回复
热议问题