Fixed: setTextColor of CPTextField changed the color of the placeholder

Previously, the method setTextColor changed the color of the placeholder as well.
Now it doesn't as in cocoa

Test app in Test/Manual/CPTextFieldEditingStyleTest
This commit is contained in:
Alexandre Wilhelm
2014-06-19 21:05:17 -07:00
parent 5d5d03fd4c
commit 3b9a0124fa
+18 -1
View File
@@ -665,7 +665,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
contentRect = [self contentRectForBounds:[self bounds]],
verticalAlign = [self currentValueForThemeAttribute:"vertical-alignment"];
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPThemeStateEditing] cssString];
if ([self hasThemeState:CPTextFieldStatePlaceholder])
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder] cssString];
else
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPThemeStateEditing] cssString];
if (CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM))
element.style.font = [font cssString];
@@ -1782,6 +1785,20 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
#pragma mark Overrides
/*!
Sets the text color of the receiver.
@param aColor - A CPColor object.
*/
- (void)setTextColor:(CPColor)aColor
{
// We don't want to change the text-color of the placeHolder of the textField
var placeholderColor = [self valueForThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
[super setTextColor:aColor];
[self setValue:placeholderColor forThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
}
- (void)viewDidHide
{
[super viewDidHide];