Search code examples
objective-ccocoansbuttonnsbuttoncell

Custom NSButton and NSButtonCell


I'm trying to create a custom button look.

From what I've gathered, NSButtonCell does the drawing, so I should actually be overwriting that instead.

But the issue is, my CustomButton class has other things like NSImage, mIsMouseOver etc. Currently the drawing is being done in the CustomButton class but I want to move it over to the cell.

question is, is there anyway I can access the image in the customButton class from the customButtonCell class so that I may use [image drawInRect:...]?

Regards, Han


Solution

  • Your cell's drawWithFrame:(NSRect)frame inView:(NSView *)controlView method includes a reference to the NSView being drawn from which you can access the view's properties (such as image).