Highlighting custom buttons when pressed, how?
Highlighting custom buttons when pressed, how?
- Subject: Highlighting custom buttons when pressed, how?
- From: Ken Tozier <email@hidden>
- Date: Sat, 14 May 2005 04:57:41 -0400
I wrote a custom NSButtonCell subclass to create simple flat "+" and
"-" signs reversed out of a circle but can't seem to find which
method to override to cause the image swap when the button is pressed.
I tried overwriting NSButton's "highlight" method but an NSLog inside
the method shows that it is never called on button pushes. My "-
(void) drawWithFrame:(NSRect) cellFrame inView:(NSView *)
inControlView" method is getting called, but I don't know what button
method is triggering that call. I assume the caller is the method
that will need to be overwritten but don't know who the calling
method is.
Anyone know?
Thanks
Ken
Here's the code:
(NOTE: this never gets called, but it's basically what I want to do
immediately before drawing the button.)
- (void) highlight:(BOOL) inFlag
{
NSLog(@"entered the highlight method");
if (inFlag == YES)
{
[currentColor release];
currentColor = [NSColor cyanColor];
}
else
{
[currentColor release];
currentColor = [NSColor controlShadowColor];
}
}
Here's the draw method: (which is getting called)
- (void) drawWithFrame:(NSRect) cellFrame
inView:(NSView *) inControlView
{
NSLog(@"entered the drawWithOrigin method");
[inControlView lockFocus];
[currentColor set];
[background fill];
[[NSColor whiteColor] set];
[sign stroke];
[inControlView unlockFocus];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden