1

I'm programming a mac app and I want to support the touchbar. I have a split screen controller and in one of the views is a AVPlayer. The AVPlayer automatically created touchbar buttons for pause and play etc. how can I remove this touchbar that's automatically created? Or is there a way to disable the touchbar for a viewcontroller? I want to add one touchbar for the window in the windowcontroller and at the moment it is overwritten by the touchbar that's automatically crated by AVPlayer.

user2403221
  • 435
  • 1
  • 3
  • 12
  • Does anybody know how to do this? Like for example disable the touchbar for all viewcontrollers and only display the touchbar of the windowcontroller? – user2403221 Jun 16 '17 at 11:11
  • 1
    Try creating your touchbar on the NSWindow itself and add an ".otherItemsProxy" item to the default identifiers and leave plenty of room. This way the AVPlayer touchbar *should* insert itself in the window's one. // I don't think you can *replace* the AVPlayer one with yours, that's why I suggest this solution (not tested, unfortunately, it's just an idea). – Eric Aya Jun 21 '17 at 09:56
  • thanks for you idea I'll report back as soon as possible (I'm trying it out today). Do you mean adding ".otherItemsProxy" as the first item in myBar.defaultItemIdentifiers = [.otherItemsProxy, ...] like that? – user2403221 Jun 21 '17 at 12:47
  • 1
    Yes but at the end: `[.stuff, .thing, .otherItemsProxy]`. Note that I haven't tested, so maybe it doesn't work. But I would try that, in your case. – Eric Aya Jun 21 '17 at 12:50
  • 1
    The idea is that the touchBars are prioritized like this: first the AppDelegate, then the NSWindow, then the NSView, then the subviews, etc. So if you have a touchBar with a proxy at the window level, then the items at the view level should insert themselves where the .otherItemsProxy is. At least that's what I understand from the documentation and WWDC videos... :) – Eric Aya Jun 21 '17 at 12:52
  • Your solution worked thank you very much! That said I hope Apple adds a solution to remove touchbar object for certain viewcontrollers :) – user2403221 Jun 21 '17 at 19:17
  • Great news! I've made a proper answer with this solution. – Eric Aya Jun 21 '17 at 21:06

1 Answers1

1

Try creating your touchbar on the NSWindow itself and add an .otherItemsProxy item to the default identifiers:

[.stuff, .thing, .otherItemsProxy]

This way the AVPlayer touchbar should insert itself in the window's one (I don't think you can replace the AVPlayer one with yours).

The idea is that the touchBars are prioritized like this: first the AppDelegate, then the NSWindow, then the NSView, then the subviews, etc.

So if you have a touchBar with a proxy at the window level, then the items at the view level should insert themselves where the .otherItemsProxy is.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253