I have an application with many NSToolbarItems. Only 5 or so are needed at any one time so it seems like the best way to fit them on the screen and make them easy to get to is to hide/display only the NSToolbarItems depending on the context.
I can't find either through google or in the Apple doc's how to do this. Is there a way? (Short of actually writing a custom nstoolbar!)
NB: I am worried this is a little bit "anti" the user interface standards, but I cannot think of a better way to handle large number of buttons that are all needed by the user, except maybe a tool window thingy.
You can go through all the items with -[NSToolbar items]
, and remove unwanted ones with -[NSToolbar removeItemAtIndex:]
, Although apple does say this:
Typically, you should not call this method (
-[NSToolbar removeItemAtIndex:]
); you should let the user reconfigure the toolbar.
Usually you just disable the toolbar items that can't be used in the current context.