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:

enter image description here

however, want redraw background (the highlight), , retain ability use main functionality of extended cell:

enter image description here

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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -