Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide an NSToolbarItem using code?

I have a toolbar with various options and some options should not be visible in some cases. I have already figured out a way to disable them in my application, using this callback:

  - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem

But I haven't figured out a way to really hide them when I need. Anyone has any ideas on how to do this or if it's really possible at all?

like image 510
Maurício Linhares Avatar asked Feb 10 '11 22:02

Maurício Linhares


2 Answers

If disabling them is not enough you could remove the items.

[myToolbar removeItemAtIndex:itemIndex];

Then when you need to put them back, just re-insert them:

[myToolbar insertItemWithItemIdentifier:itemIdentifier atIndex:itemIndex];

Look at Adding and Removing Toolbar Items in the Apple docs.

like image 53
David Avatar answered Nov 12 '22 02:11

David


No built-in visibility property for buttons. Remove it from the toolbar and re-add when needed.

like image 34
Seva Alekseyev Avatar answered Nov 12 '22 02:11

Seva Alekseyev