NSWindowToolbarStylePreference toolbar buttons don't have preference style

In Big Sur when I use window.toolbarStyle = NSWindowToolbarStylePreference and set toolbar.displayMode = NSToolbarDisplayModeIconAndLabel the toolbar buttons don't take on the Preferences style.

The hover and click state is only over the icon when it should be a large box surrounding the icon and label. These are the normal toolbar button styles. How do I get the buttons to take on the Preferences style?

I've had to resort to using window.contentViewController = NSTabViewController to get the right toolbar button style.

Is there something special I need to do to get NSWindowToolbarStylePreference to work?

Answered by Frameworks Engineer in 786350022

Hi eablokker,

On your NSToolbarDelegate, implement -toolbarSelectableItemIdentifiers: to return all of these item identifiers to give them the "you can click to select the whole toolbar item" behavior. Note also that to match the preference style, your items should have the bordered property set to false, since you won't need a separate button inside the item.

Accepted Answer

Hi eablokker,

On your NSToolbarDelegate, implement -toolbarSelectableItemIdentifiers: to return all of these item identifiers to give them the "you can click to select the whole toolbar item" behavior. Note also that to match the preference style, your items should have the bordered property set to false, since you won't need a separate button inside the item.

NSWindowToolbarStylePreference toolbar buttons don't have preference style
 
 
Q