Re: +[NSColor highlightColor] in NSTableView
Re: +[NSColor highlightColor] in NSTableView
- Subject: Re: +[NSColor highlightColor] in NSTableView
- From: Graham Cox <email@hidden>
- Date: Mon, 2 Feb 2009 09:41:28 +1100
On 2 Feb 2009, at 1:46 am, Jerry Krinock wrote:
+[NSColor selectedTextBackgroundColor] definitely gives a color
based on System Preferences > Appearance > Highlight Color (for
selected text). However, the color actually used in NSTableView is
darker than this.
For example, I set the color in System Preferences to RGB = {255, 0,
255}, but when I use DigitalColor Meter.app on a highlighted cell in
a "stock" NSTableView, I measure {204, 0, 204}. Now, 204=51*4 and
255=51*5. So it looks like someone in the NSTextFieldCell
Department decided to reduce the brightness by 20%, because, of
course, if someone set their "highlight" (sic) color to all white,
the white text drawn on it by NSTextFieldCell would be invisible.
So, I was able to match the "stock" NSTextFieldCell using a little
brightness-tweaking method that I had lying around. Is this 20%
reduction in brightness documented anywhere? I even searched Human
Interface Guldelines for "highlight" but didn't find any mention of
this.
Interestingly, in NSTextViews (TextEdit docs, this message in
Mail.app), the text is drawn in black instead of white, and the 20%
reduction is not applied. And then, Xcode's editor ignores my
System Preferences and uses black on orange, like it or not. Seems
like we need some User Interface Police here.
***************************************************
color = [NSColor selectedTextBackgroundColor] ;
color = [color colorTweakBrightness:-.20] ;
Just to make sure you're aware of it, but -[NSColor shadowWithLevel:]
(and its sister method, -[NSColor highlightWithLevel:]) are darkening
and brightening methods that NSColor has - there's no need to write
your own unless they're doing something unusually funky.
I can't shed any light on what NSTableView uses, maybe Corbin could
let you know? (I modified the title of the message so he might notice
it ;-)
Xcode is using my system prefs for text highlight here - never seen
black on orange, maybe your editor settings have been changed at some
point?
--Graham
_______________________________________________
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