What would I do in my override? Temporarily set the text color, call
super, and then revert it back?
Ken Ferry wrote:
> The way NSCell deals with this is that the white color is never part
> of the value data itself, it's thought of as a draw-time visual
> effect.
>
> That is, rather than calling setTextColor, you could override
> -drawInteriorWithFrame:inView:.
>
> -Ken
>
> On Tue, Feb 26, 2008 at 11:35 AM, John Stiles <email@hidden> wrote:
>
>> Actually, for what it's worth, I did just hit one snag. If you attempt to
>> edit the cell, the field editor inherits the white color! This makes it
>> pretty difficult to see what you're doing ;)
>>
>> I have a custom field editor anyway and have lots of control over how the
>> edit process gets started, so it was no problem to force the field editor to
>> use the actual item color, but I figured this was worth mentioning, for the
>> archives if nothing else.
>>
>>
>>
>>
>> John Stiles wrote:
>> Six of one and a half dozen of the other? :)
>> Anyway, it looks like this does the trick:
>> ([cell isHighlighted] && [[outlineView window] isKeyWindow] &&
>> [[outlineView window] firstResponder] == outlineView)
>>
>> Not quite as clean and nice as "backgroundStyle" but it will have to do for
>> now :)
>>
>> Ken Ferry wrote:
>> Also, I'd be pretty surprised if this actually showed up in perf
>> profiling. Do you mean 'heavyweight', or annoying? :-)
>>
>>
>>
>> > but it seems a lot more heavyweight. You have to do:
>> >
>> > [[outlineView selectedRowIndexes] containsIndex:[outlineView
>> rowForItem:item]]
>>
>> -Ken
>>
>> On Mon, Feb 25, 2008 at 6:26 PM, Ken Ferry <email@hidden> wrote:
>>
>>
>> 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
>> >
>>
>>
>>
>>