I have a project that needs to disable/enable some NSToolbarItem
s depends on different options. I checked and found no parameter for this.
Is there a way to enable/disable a given NSToolbarItem
?
I have a project that needs to disable/enable some NSToolbarItem
s depends on different options. I checked and found no parameter for this.
Is there a way to enable/disable a given NSToolbarItem
?
an easy way to do this in swift, or you could port this to objective c is to just set actions
This Disables the item
Mytoolbar.action = nil
This reEnables it
Mytoolbar.action = "Name of a function"
In doing this you would want to replace your IBAction with function so
@IBAction func blehbleh(sender: AnyObject){ Stuff }
would be changed to
func blehbleh(){ Stuff }
Implement NSToolbarItemValidation Protocol in your window, view or document controller. The documentation gives the following sample code:
You can also use
action
ortag
to determine what toolbar item is being validated. Items are validated frequently, whenever your app is activated or events are dispatched, so they will always be in a valid state.