Re: Highlighting custom buttons when pressed, how?
Re: Highlighting custom buttons when pressed, how?
- Subject: Re: Highlighting custom buttons when pressed, how?
- From: Ryan Stevens <email@hidden>
- Date: Sat, 14 May 2005 08:05:36 -0700
On May 14, 2005, at 1:57 AM, Ken Tozier wrote:
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];
}
You might just check -isHighlighted in -drawWithFrame:inView: and then
draw appropriately....if I remember from last time this came up.
_______________________________________________
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