• 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
Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item


  • Subject: Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item
  • From: Corbin Dunn <email@hidden>
  • Date: Thu, 28 Feb 2008 12:09:12 -0800


On Feb 26, 2008, at 10:21 PM, Seth Willits wrote:
On Feb 26, 2008, at 3:13 PM, John Stiles wrote:

Trying to simulate the drawing behavior of NSCell seems error-prone to me. Since I don't have access to the original code, it would be hard to match its behavior. I'd much rather inherit as much as I can and only customize around the edges.

You're not replicating a whole lot here, however. If you're already setting the multi-colored text color in willDisplayCell: for every cell, then the minimal amount of work you need should be to call setTextColor before calling the super class's implementation of drawInteriorWithFrame if the cell is highlighted and active.



- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
{
BOOL isWindowActive = [[[self controlView] window] isKeyWindow] && [[NSApplication sharedApplication] isActive];
BOOL isControlActive = isWindowActive && ([[[self controlView] window] firstResponder] == [self controlView]);


	if (isControlActive && [self isHighlighted]) {
		[self setTextColor:[NSColor whiteColor]];
	}

	[super drawInteriorWithFrame:cellFrame inView:controlView];
}


I should mention a few things about this snippet of code. Under leopard, the "isKeyWindow/isActive" stuff isn't required; you can just use something like this:

BOOL isControlActive = [self interiorBackgroundStyle] == NSBackgroundStyleLight;
...
This will be correct in more places than the above example (which would be wrong for edited text).


Also, if you call setTextColor for one case, you should call setTextColor for the other 'else' clause too. Otherwise, any drawings with the same cell will use the last color set (white), unless your willDisplayCell resets it.

corbin
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


References: 
 >- outlineView:willDisplayCell:forTableColumn:item: and selected item (From: John Stiles <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: "Ken Ferry" <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: "Ken Ferry" <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: John Stiles <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: John Stiles <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: "Ken Ferry" <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: John Stiles <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: "Ken Ferry" <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: John Stiles <email@hidden>)
 >Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Drawing from secondary thread erases resize corner in window? [solved, for now]
  • Next by Date: Re: Table views with different NSArrayControllers sharing the same data object...
  • Previous by thread: Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item
  • Next by thread: Failed to capture Key Equivalent on Mac 10.4 but Succeeded on Mac 10.5
  • Index(es):
    • Date
    • Thread