• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Highlighting custom buttons when pressed, how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Highlighting custom buttons when pressed, how?
      • From: Ryan Stevens <email@hidden>
  • Prev by Date: RBSplitView Rave
  • Next by Date: RAM Location and Size in 64bits Machines
  • Previous by thread: RBSplitView Rave
  • Next by thread: Re: Highlighting custom buttons when pressed, how?
  • Index(es):
    • Date
    • Thread