Disabling non-editable NSTextFields
Disabling non-editable NSTextFields
- Subject: Disabling non-editable NSTextFields
- From: Peter Lindberg <email@hidden>
- Date: Fri, 13 Feb 2004 15:22:21 +0100
(Sorry for crossposting.)
This is strange. Disabling a label, that is a non-editable NSTextField,
still renders the text black. Why is this? When disabling a group of
controls, you'd naturally want their labels to go gray as well.
Even more strange is that the setEnabled: method seems to decide based
on its background color whether or not the text should go gray. By
default it doesn't have a background, but if you set it to white, for
instance, it works. But setting the background color to
windowBackgroundColor doesn't work, still black.
Instead, I decided to subclass NSTextField and override setEnabled: to
set the appropriate text color. But then things got even more strange.
Naturally, I checked the flag passed and set the color accordingly, but
it stayed black. After a little experimenting, I found out that if I
always set disabledControlTextColor, the text is gray when it's
enabled, and black when it's disabled. So if I check the flag, it will
stay black.
One awkward option, but one that works, would be to bind textColor for
the labels to methods that return either controlTextColor or
disabledControlTextColor depending on the state of the above controls.
But it just doesn't feel right. I have several labels that should
enable at different times.
What's the correct way to do this? Is this a bug or does it behave as
intended?
/P.
--
Peter Lindberg
Computer Programmer, Oops AB, Sweden
http://oops.se/
http://tesugen.com/weblog
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.