Search code examples
macoscocoanstoolbarnstitlebaraccessoryviewcontroller

Add NSTitlebarAccessoryViewController to the left of the titlebar/toolbar


I have implemented a unified titlebar/toolbar and now would like to add two buttons to the bar. They need to be located at the far left, just right of the stoplight buttons. I'm creating a toolbar that's very similar to System Preferences.

I have looked at the API for adding NSTitlebarAccessoryViewController and the only valid properties for layoutAttribute are NSLayoutAttributeRight (adds the view to the far right of the toolbar) and NSLayoutAttributeBottom which essentially places the view underneath the unified toolbar in its own toolbar.

I want neither of those options, so how would one add a bunch of buttons to the very left of the unified toolbar?

enter image description here


Solution

  • This is now possible in OS X 10.11. Quoting from the header file:

    For applications linked on Mac OS 10.11 or later, NSLayoutAttributeLeft is also supported; placing the item on the left side of the window (adjacent and to the right of the close/minimize/maximize buttons).