1

I am implementing a preferences window, with a subclass of NSToolbarItem that has an IBOutlet to an NSView (the idea being that when an item is clicked, it will display its view). However, when I connect a toolbar item to an instance of the subclass, that item's image disappears and it is not clickable (although the text remains dark and does not fade).

If I disconnect the IBOutlet, everything works again (well, nothing does, since it isn't bound to the view, but you get the idea).

  • Is it a plain NSView, some other kind of stock Cocoa view, or a custom view? What do you mean by “when I connect a toolbar item to an instance of the subclass [of NSToolbarItem]”? What action are you hooking the toolbar item up to? – Peter Hosey Jul 04 '11 at 08:22

1 Answers1

1

Connecting the view to the NSToolbarItem actually sets the view where the toolbar item's image normally is. This is useful in cases where you need a view in the toolbar (for example, the iTunes volume slider), but not in your case.

What you need to do is create an NSViewController for your view, and create an IBAction that shows the view. You should be able to connect the IBAction to the toolbar item (in Interface Builder), and everything should work as expected.

spudwaffle
  • 2,905
  • 1
  • 22
  • 29