I'm trying to subclass NSCell
to draw a custom background highlight. The documentation seems to suggest that the overriding highlight:withFrame:inView:
should allow me to do this but the method is never called.
Instead, I've overridden drawInteriorWithFrame:inView:
which works fine - I can draw what I want in the cell. However, the issue is that I have to draw everything myself, losing the functionality of the type of NSCell I am extending - for example an NSTextFieldCell's ability to display text:
Custom drawn highlighted cell:
However, I just want to redraw the background (the highlight), and retain the ability to use the main functionality of the extended cell:
I could, of course, just draw the text myself too but I'm hoping there is an easier way of doing this.
Any help is much appreciated.
[super drawInteriorWithFrame:cellFrame inView:controlView];
(with whatever parameter names you’re using) after you’ve drawn your custom background? – user557219super
won’t mess with your custom highlight, and then you use-isHighlighted
inside-drawInterior…
to decide how you should draw the background? – user557219highlightColorWithFrame:inView:
just showed through to the desktop like i.imgur.com/jy970.png. However, returning nil for the same method did what I wanted - i.imgur.com/joUom.png - thanks for your help! – JoeR