How to add two touching toolbar items to NSToolbar
Asked Answered
S

1

6

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!

Selfinduced answered 30/4, 2016 at 18:32 Comment(3)
Would an NSSegmentedControl work?Conjugate
That is a possibility, if it is possible to turn off borders for the control, so that only the button borders are showing. I'll give that a try tonight, thanks!Selfinduced
@Conjugate That didn't do the trick. The NSSegmentedControl shows its own border, and doesn't allow me to set an NSView for a segment--only images or labels.Selfinduced
A
9

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

Aras answered 10/5, 2016 at 1:59 Comment(1)
That's it, thank you! I had to change the style to separated, and now it's perfect!Selfinduced

© 2022 - 2024 — McMap. All rights reserved.