cocoa - NSCell Custom Highlight -
i'm trying subclass nscell
draw custom background highlight. documentation seems suggest overriding highlight:withframe:inview:
should allow me method never called.
instead, i've overridden drawinteriorwithframe:inview:
works fine - can draw want in cell. however, issue have draw myself, losing functionality of type of nscell extending - example nstextfieldcell's ability display text:
custom drawn highlighted cell:
however, want redraw background (the highlight), , retain ability use main functionality of extended cell:
i could, of course, draw text myself i'm hoping there easier way of doing this.
any appreciated.
thanks of @bavarious i've managed work out. extended nstextfieldcell class implementation contains:
-(nscolor *)highlightcolorwithframe:(nsrect)cellframe inview:(nsview *)controlview { return nil; } - (void)drawwithframe:(nsrect)cellframe inview:(nsview *)controlview { if ([self ishighlighted]) { // draw highlight background here } [super drawinteriorwithframe:cellframe inview:controlview]; }
the key make sure return nil
highlightcolorwithframe:inview:
stop drawinteriorwithframe:inview:
drawing background , yet still calling draw main content (in case text).
Comments
Post a Comment