nanochrome
nanochrome

Reputation: 727

What class to subclass - NSView or NSButton

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

Upvotes: 1

Views: 988

Answers (3)

TechZen
TechZen

Reputation: 64428

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.

Upvotes: 1

Steve Streza
Steve Streza

Reputation: 253

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.

Upvotes: 7

Sneakyness
Sneakyness

Reputation: 5403

UIButton has a custom option in Interface Builder.

Upvotes: -2

Related Questions