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?

Accepted Reply

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.

  • Thank you @.jsn that worked! I also noticed that the background color of the toolbar is slightly different than a tabview preferences window, when the window is selected. It is slightly whiter in light mode and slightly blacker in dark mode. For example #363636 vs #1E1E1E in dark mode. Is there anything else I need to do to get the toolbar color to match a tabview preferences window, or is this just a minor design oversight that I should ignore?

Add a Comment

Replies

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.

  • Thank you @.jsn that worked! I also noticed that the background color of the toolbar is slightly different than a tabview preferences window, when the window is selected. It is slightly whiter in light mode and slightly blacker in dark mode. For example #363636 vs #1E1E1E in dark mode. Is there anything else I need to do to get the toolbar color to match a tabview preferences window, or is this just a minor design oversight that I should ignore?

Add a Comment