• 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
NSBrowserCell state and isHighlighted
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBrowserCell state and isHighlighted


  • Subject: NSBrowserCell state and isHighlighted
  • From: "Alan Smith" <email@hidden>
  • Date: Sat, 2 Dec 2006 09:09:19 -0500

Hello all,

I'm trying to make a subclass of NSBrowserCell and I'm confused about
using the 'state' and 'isHighlighted' methods of NSBrowserCell.

When I override the drawing I use isHighlighted to know if I should
draw the "current" (normally blue) color or the "clicked but no longer
current" (normally gray) state. For some reason the cell highlights
but then almost immediatly becomes "inactive." (Gray.) If I don't
override any methods it works fine, of course. What am I *not* doing
that Apple does? I hope it's trivial.

- (void)_drawHighlightWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
	NSLog(@"Highlighting NSBrowserCell: %@", self);
	NSLog(@"State = %i and isHighlighted = %i of %@", [self state], [self
isHighlighted], self);

	[self setTitle: [NSString stringWithFormat: @"%i : %i", [self state],
[self isHighlighted]]];
	NSColor *color = nil;

	if ([self state] == NSOffState && [self isHighlighted] == YES)
	{
		color = [self activeColor];
	}
	else
	{
		color = [self inactiveColor];
	}

	if (color != nil)
	{
		if ([[color colorSpaceName] isEqualToString: @"NSPatternColorSpace"])
		{
			NSImage *image = [color patternImage];

			[image setFlipped: [controlView isFlipped]];
			[image fillHorizontalRect: cellFrame];
		}
		else
		{
			[color drawSwatchInRect: cellFrame];
		}
	}
}

I know I shouldn't override private methods but I'm going to do it
this way until I get this working.

Please help, I've been bashing my head for the last two days on this.
Thanks in advance, Alan

--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that religion really is unnecessary, then it
shall evolve."
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: NSImage TIFFRepresentation memory leak
  • Next by Date: iPhoto like mail composing
  • Previous by thread: ANN: BaseTen DP1 (Cocoa database framework)
  • Next by thread: iPhoto like mail composing
  • Index(es):
    • Date
    • Thread