views:

197

answers:

3

I am creating a button and should I subclass NSView and or NSButton?

A: 

UIButton has a custom option in Interface Builder.

Sneakyness
1. I'm on a mac. 2. I want to do my own custom drawing
nanochrome
NSButton != UIButton
0xced
I'm aware of that, I've been balls deep in iPhone coding so I had thought he mis-spoke.
Sneakyness
+6  A: 

If you only want to do custom drawing, consider subclassing NSButtonCell, which is the class responsible for drawing within a button. If that's not powerful enough to do what you want, you should subclass NSButton, as it'll give you lots of behavior for free, and will let you set up the button in Interface Builder as you would any other control.

Steve Streza
+1  A: 

You very seldom have to subclass to get the button appearance you want. You can load a button up with images for various states and you can make it into any rectangular shape or size.

If you want can't get what you want from NSButton, then look look at subclassing NSControl instead of NSView. That way, you get the interaction methods.

TechZen