From 3b9a0124fa73574f755daca988fc945bc49fc455 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 19 Jun 2014 21:05:17 -0700 Subject: [PATCH] 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 --- AppKit/CPTextField.j | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 85f7e3d8a..899c460b9 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -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];