Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add two touching toolbar items to NSToolbar

I want to add two touching items, such as a forward and back button, to NSToolbar, like so:

enter image description here

NSToolbar seems to add horizontal margins by default, for each item, like this:

enter image description here

I checked out the XIB source code under the toolbarItem node, and there is no property/attribute that would provide a margin or padding.

Thanks for your help!

like image 715
Sheamus Avatar asked Apr 30 '16 18:04

Sheamus


1 Answers

I do use NSSegmentedControl for this which allows me to use my own images, labels, set custom actions, use a toggle, set a menu, etc. If this type of toolbar item works for you:

segmented control toolbar items

then you can see how I build these items in IB & code in this project (note that the AppDelegate class is the delegate for the NSToolbar):

TouchingToolbar.zip

If you really want the two items separated (but close together), set the style of the NSSegmentedControl in IB from Rounded to Separated:

enter image description here

like image 59
Jon Avatar answered Oct 18 '22 18:10

Jon