NSTextField doesn't change its text color if the field is enabled or disabled (?) Even more bizarre, using NSColor'sdisabledControlTextColor
won't draw the text in the disabled color. You need to use thesecondarySelectedControlColor
, which supposedly is for active controls that don't have focus. Go figure.To do it yourself, subclass NSTextField and override
setEnabled:
to change the color:- (void) setEnabled: (BOOL) flag { [super setEnabled: flag]; if (flag == NO) { [self setTextColor: [NSColor secondarySelectedControlColor]]; } else { [self setTextColor: [NSColor controlTextColor]]; } } // setEnabledThis actually kind of a gross workaround for a Cocoa bug - the disabled color is getting made darker rather than lighter. The secondarySelectedControlColor ends up looking disabled by a happy coincidence that it starts out lighter before being darkened. (or something like this. UberDude Dave MacLachlan has done the legwork to figure out the underlying problem.)