2

I have a NSButton on a view I subclass the NSView and draw something in the drawRect:, and the view is belong to a NSWindow which

Then when I click the button, I find the view become transparent, which I guess is because the button click changes the button's background. So I subclass the NSButton,

- (void)mouseDown:(NSEvent *)theEvent {

[self.window.contentView setNeedsDisplay:YES];
[super mouseDown:theEvent];
[self.window.contentView setNeedsDisplay:YES];

}

Right now when I mouseDown and mouseUp, the view seems right, except there is a flash transparent when I click, even more, when I mouseDown and move out of the button, the background becomes transparent again.

Can anyone tell me what should I do to make the background of a clicked button do not change?
or where to put the redraw code.

THANKS!

aug2uag
  • 3,379
  • 3
  • 32
  • 53
Daniel Gao
  • 293
  • 2
  • 7
  • Does this help? http://stackoverflow.com/questions/3797640/borderless-nsbutton-turns-gray-when-clicked – Erik Godard Aug 15 '13 at 03:15
  • @ErikGodard Yes, I found that question before, and this does not help. My button is push style and Momentary Push In type, and I do not want change the style and type – Daniel Gao Aug 15 '13 at 03:31

0 Answers0