João Oliveira
João Oliveira

Reputation: 452

NSToolbarFlexibleSpaceItem is constraint to NSSplitViewItem in Swift

enter image description here

Almost all macOS official apps have this toolbar's feature which the NSToolbarItem flexible space is constraint to NSSplitViewItem view. I first thought maybe there are 3 different sections on NSToolbar. But it just ONE toolbar. You can open Notes app and customize the toolbar.

I guess this is how Apple configure the flexible space items.

I found this JWToolbarAdaptiveSpaceItem but it's removable and it cannot be replaced with flexible space item like Note apps does.

There is another stackoverflow's question (I couldn't find it now) asked about this but the answer is adding fake views and buttons which is not NSToolbar.

Thus, does anyone know how to achieve this?

(Sorry about my English)

Upvotes: 7

Views: 558

Answers (1)

Kevin Grant
Kevin Grant

Reputation: 5431

As of macOS 11 Big Sur, this is handled by NSTrackingSeparatorToolbarItem, which interacts with the dividers of an NSSplitView. There is also a new navigational property on NSToolbarItem that can influence item locations.

I do not think there is a built-in way to do this on previous macOS versions.

Upvotes: 1

Related Questions