I have an application that will be available across multiple versions of OS X. What's the best way to make an NSToolbarItem
only available to users in certain OS versions. When it is not available, it should be completely hidden, not just disabled.
To simplify, how do I remove a toolbar item from this (below) menu programmatically?
Edit: I tried to override toolbarAllowedItemIdentifiers:
in the delegate like so:
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
NSLog(@"Toolbar requesting allowed items.");
NSMutableArray *array = [NSMutableArray array];
[array addObject:@"TPUpToolbarItem"];
[array addObject:@"TPDownToolbarItem"];
[array addObject:@"TPResetToolbarItem"];
[array addObject:@"TPSpeedToolbarItem"];
[array addObject:@"TPGroupToolbarItem"];
[array addObject:@"TPBackgroundToolbarItem"];
[array addObject:NSToolbarShowFontsItemIdentifier];
if (floor(NSAppKitVersionNumber) <= 1038) {
NSLog(@"Below Lion, adding Fullscreen item.");
[array addObject:@"TPFSToolbarItem"];
}
[array addObject:@"TPFlipHToolbarItem"];
[array addObject:@"TPFlipVToolbarItem"];
[array addObject:NSToolbarFlexibleSpaceItemIdentifier];
[array addObject:NSToolbarSpaceItemIdentifier];
[array addObject:NSToolbarSeparatorItemIdentifier];
[array addObject:NSToolbarShowColorsItemIdentifier];
[array addObject:NSToolbarPrintItemIdentifier];
return array;
}
All the other toolbar items show in the correct order, however the Fullscreen item is last, and still there.
Thanks in advance.