You can add the NSToolbarItem object to the toolbar, and then set the NSViewController as follows (using Swift):
runStatus.view = RunStatusView()
where "runStatus" is the name of @IBOutlet for NSToolbarItem, and "RunStatusView" is an NSView object with an override of the drawRect method. You can also specify the width and height of the NSView; for example, make the width constant at 125:
runStatus.minSize = NSSize(width: 125, height: 32) runStatus.maxSize = NSSize(width: 125, height: 32)
This can cause NSToolbar elements to be closer to each other, depending on what you draw on them.
Finally, if you still cannot get exactly what you want, make the button group one NSToobarItem, and in "RunStatusView" (using the example above) draw it as you want and redefine the mouseDown event (also in "RunStatusView") to see exactly where the user clicks. Then there is one NSToolbarItem element that essentially acts like a few buttons, and you have full control and can make it behave as you like.
source share