Space Vatican

Ramblings of a curious coder

Selectable Items in NSToolbar

NSToolbar has a mode where the toolbar items are selectable - this is commonly used to create preference windows, each item in the toolbar representing a section. If your delegate responds to toolbarSelectableItemIdentifiers: then the toolbar will allow these items to be selected.

You can do all this in IB (along with the rest of the standard NSToolbarDelegate stuff), since IB allows you to mark items as selectable.

The bit that confused me is that unless you also assign an action to the toolbar item (I’ve got mine pointing at a selectSection: method) then nothing will happen when you click the toolbar items, not even a change of selection state. Nowhere does this seem to be documented. I expected that even though I’d hooked up no actions and the toolbar wouldn’t be useful I would at least be able to play with the selection state. Hopefully this helps anyone else wondering why their toolbar isn’t working.