Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable the Show Tab Bar menu option in Sierra apps?

I've got an app that uses a Toolbar in a NSWindow. I don't want users to be able to customize this toolbar for aesthetic reasons. In Sierra there's a new Menu option that gets inserted into "Menu > View" called Show Tab Bar. How do I disable this? Enabling it only seems to increase the tool bar's height as I don't have extra labels showing under the icons.

like image 727
strangetimes Avatar asked Sep 08 '16 20:09

strangetimes


4 Answers

You can also do this on IB, on the Window’s attributes inspector

NSWindow attribute inspector

like image 169
leonaka Avatar answered Nov 14 '22 21:11

leonaka


On 10.12, you need to now set the following when the window is created as Tab Bar is now available by default:

[NSWindow setAllowsAutomaticWindowTabbing: NO];

The answer is the same in Swift and SwiftUI

func applicationWillFinishLaunching(_ notification: Notification) {
    NSWindow.allowsAutomaticWindowTabbing = false
}

Note that the call is made on the class NSWindow not on an instance of NSWindow

like image 27
strangetimes Avatar answered Nov 14 '22 21:11

strangetimes


To disable tabbing on individual windows call setTabbingMode:

if([window respondsToSelector:@selector(setTabbingMode:)]) {
    // this particular window doesn't support tabbing in Sierra.
    [window setTabbingMode:NSWindowTabbingModeDisallowed];
}
like image 5
adib Avatar answered Nov 14 '22 23:11

adib


If you don't want to compile against the latest frameworks, you can use the following code in your NSWindowsController sub classes:

Swift:

 override func awakeFromNib() {
     if NSAppKitVersionNumber > 1500 {
        self.window?.setValue(2, forKey: "tabbingMode")
     }
 }

Objective-C:

- (void)awakeFromNib {
    if (NSAppKitVersionNumber > 1500) {
        [self.window setValue:[NSNumber numberWithInt:2] forKey:@"tabbingMode"];
    }
}
like image 4
Ely Avatar answered Nov 14 '22 23:11

Ely