cocoa - Custom NSTextFieldCell and background drawing -


i created custom nstextfieldcell , overwrote - (void)drawinteriorwithframe: (nsrect)cellframe inview: (nsview *)controlview own drawing here. however, have trouble background drawing. without calling super background not cleared , subsequent drawings create smear effect. not happen when drawsbackground set, in case can fill cellframe 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]; } 

enter image description here

but have clear background in case background drawing disabled? want let other content under text view shine through of course (so, erasing superview's background color no solution).

if try fill cell [nscolor clearcolor] draw black. try avoid fill when not needed. , able remove super call.

example:

- (void)drawinteriorwithframe:(nsrect)cellframe inview:(nsview *)controlview {     if (self.drawsbackground) {         if (self.backgroundcolor && self.backgroundcolor.alphacomponent>0) {              [self.backgroundcolor set];             nsrectfill(cellframe);         }     }     nsrect titlerect = [self titlerectforbounds:cellframe];     nsattributedstring *atitle = [self attributedstringvalue];     if ([atitle length] > 0) {         [atitle drawinrect:titlerect];     } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -