Skip navigation.
 
mlRe: How to disable/gray an NSTextfield (used as static text)
FROM : Dave MacLachlan
DATE : Fri Jul 21 00:30:35 2006

> The text field on the right was set to disabledControlTextColor 
> *within
> IB* (via Developer color palette).  The text field on the left is 
> set to
> disabledControlTextColor *with setTextColor:*.  Yet they don't 
> match.  As
> you say, if I use secondarySelectedControlColor, they match.
>
> Why is that?


To resurrect a age-old thread that never really got resolved..

4642547 Static Text in Cocoa draws "disabled" incorrectly

So I did some research on this because I was running into problems 
with it as well...basically here's what I found.

Take a look at this screen shot of IB:

http://homepage.mac.com/dmaclach/bugs/radar4642547.png

NSTextFields DO change color when they are disabled, however I think 
somebody was trying to be clever and change the brightness and 
changed it the wrong way. Black gets blacker when it should be 
getting lighter. This means that the standard workaround of using 
[NSColor secondarySelectedControlColor] is wrong...it just happens to 
work-out that the secondarySelectedControlColor is the right 
"lightness" that when it is darkened appropriately it looks about right.

I really think that "disabled" shouldn't lighten the color, but 
instead should set the color equivalent to 
"kThemeTextColorPopupLabelInactive" or [NSColor 
disabledControlTextColor].

This probably explains the differences that you are/were seeing Sean. 
Hopefully they'll figure out someway to fix this instead of having 
everyone subclass and do it incorrectly.

Cheers,
Dave

Related mailsAuthorDate
No related mails found.