10

I have an app that is displayed like a status bar app (in Info.plist "Application is agent (UIElement) = YES").

I have added a TouchBar with Interface Builder and I added some Touch Bar Buttons items on it. The problem is that the custom touch bar don't show.

To make the custom touch bar to show I need to make the main WindowController window as Is Initial Controller true, unfortunately, by doing so, the app sows also a separate window with the same content than the popup window of the menu item.

Is there a way to implement a custom Touch Bar for a status bar macOS app?

enter image description here

Cue
  • 2,952
  • 3
  • 33
  • 54

1 Answers1

0

Have you tried assigning touchBar to your NSApplication? You should have IBOutlet assigned with your IB touchBar and at runtime assign it.

@property (weak) IBOutlet NSTouchBar *testTouchBar;
[...]
[NSApplication sharedApplication].touchBar = _testTouchBar;
cybek
  • 49
  • 3
  • Hi cybek, I'm a beginner and don't know Objective-C, can you help me to translate it in Swift? The outlet I put in WindowController seems to work but the second statement I put in windowDidLoad(): "let t: NSApplication = application.shared.mainTouchBar` gives an error (Bool has not member shared). Surely I translated it wrong in Swift... – Cue May 11 '17 at 20:21
  • @Tel Actually I'm beginner too because I'm learning obj-c. But I hope code in swift would look like this: let app = NSApplication.shared(); app.touchBar = _testTouchBar; It looks like you used sharedApplication instead of shared in swift. And it's a method. Rest would be the same. – cybek May 11 '17 at 20:57
  • Hi cybek, I implemented it, but it does not seem to work. Thank you – Cue May 12 '17 at 16:41