How do I get NSPopUpButtonCell to re-render itself?

I am creating a custom subclass of NSPopUpButton and NSPopUpButtonCell to display a single icon on top of a button instead of plain text.

To do this, I override

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView

      

in my subclass of the button cell to draw the icon at the appropriate size and location. When the user clicks on the I button, I want to change the image. My only problem is I can't figure out how to re-render the buttons of the buttons (by calling drawInterior ... again). By default, it only appears when the button is pressed again or when the focus is moved to another window. I've tried setNeedsDisplay: YES, but it doesn't look like this.

0


source to share


1 answer


The way I found this is to insert a call

[self updateCell:self.cell];

      



inside my NSPopUpButton subclass right after any point I changed the image displayed by the cell.

+2


source







All Articles