I created a custom NSTextFieldCell and overwrote - (void)drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
to do my own drawing here. However, I have trouble with background drawing. Without calling super
the background is not cleared and subsequent drawings create something like a smear effect. This does not happen when drawsBackground is set, as in this case I can just fill the cellFrame with the background color.
- (void)drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView {
if (self.drawsBackground) {
[self.backgroundColor set];
} else {
[NSColor.clearColor set];
}
NSRectFill(cellFrame);
[self.attributedStringValue drawInRect: cellFrame];
}
But what do I have to do to clear the background in case background drawing is disabled? I want to let the other content under the text view to shine through of course (so, just erasing with the superview's background color is no solution).