Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item
Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item
- Subject: Re: - outlineView:willDisplayCell:forTableColumn:item: and selected item
- From: "Ken Ferry" <email@hidden>
- Date: Mon, 25 Feb 2008 18:26:31 -0800
The pre-leopard code isn't pretty. The AppKit relnotes give the old
path while motivating the backgroundStyle API. I'm not sure if this
is 100% complete..
> Prior to Leopard, you may have noticed that text turns white in selected table view rows. The
> mechanism that controlled this behavior, unfortunately, was arcane. The table would set the
> highlight color of the cell to the alternateSelectedControlColor and set the cell to be highlighted.
> The cell would then introspect its highlight color, and use white text if the color was the
> alternateSelectedControlColor.
You probably have a constrained case, so it may suffice to check
-isHighlighted.
It'd be nice if you could use the Leopard API on Leopard or later, as
we might try to be a little bit more clever about when the text
actually turns white. Ideally the text wouldn't turn white if the
user's chosen selection color was sufficiently light. There's scope
for making that work in the backgroundStyle API.
-Ken
On Mon, Feb 25, 2008 at 5:12 PM, John Stiles <email@hidden> wrote:
> In my outline view, I'm using an NSTextFieldCell and setting the item's
> color via setTextColor:.
>
> This works fine, but for some colors, it's almost impossible to see when
> the item is selected. I'd like to always make the text white if the item
> is selected.
>
> In Leopard, I know I can use [cell backgroundStyle] ==
> NSBackgroundStyleDark to check this, but I was wondering if there is any
> easy check for Tiger and below. I can actually go through the
> machinations of asking the outline view if the item is selected, but it
> seems a lot more heavyweight. You have to do:
>
> [[outlineView selectedRowIndexes] containsIndex:[outlineView
> rowForItem:item]]
>
> And I'm not sure just how fast that is, but it can't be as fast as just
> asking the cell "are you selected" :)
>
> _______________________________________________
>
> 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
>
_______________________________________________
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