From 57f2d3e26add1ff57fcf636c5267040563d76cce Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 4 Sep 2014 14:34:09 -0700 Subject: [PATCH] Revert "Merge pull request #2152 from daboe01/Fix-for-missing-backgroundcolor-support-textfield" This reverts commit 5c193f49df0eb59ce5f38b7681f0e5c9a744137c, reversing changes made to 5b2ef77c2ca5569da846209324550cea0a8b643a. --- AppKit/CPTextField.j | 29 ++++++++---------------- Tests/Manual/CPTextField/AppController.j | 8 +------ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index a223804fa..6ddd3716f 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -130,6 +130,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); BOOL _drawsBackground; + CPColor _textFieldBackgroundColor; + CPString _placeholderString; CPString _stringValue; @@ -531,32 +533,23 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); Sets the background color, which is shown for non-bezeled text fields with drawsBackground set to YES @param aColor The background color */ -- (void)setBackgroundColor:(CPColor)aColor +- (void)setTextFieldBackgroundColor:(CPColor)aColor { - // _backgroundColor is defined on CPView. - if (_backgroundColor == aColor) + if (_textFieldBackgroundColor == aColor) return; - _backgroundColor = aColor; + _textFieldBackgroundColor = aColor; [self setNeedsLayout]; [self setNeedsDisplay:YES]; } -/* - Deprecated. See: https://github.com/cappuccino/cappuccino/pull/2152 -*/ -- (void)setTextFieldBackgroundColor:(CPColor)aColor -{ - [self setBackgroundColor:aColor]; -} - /*! - Deprecated. See: https://github.com/cappuccino/cappuccino/pull/2152 + Returns the background color. */ - (CPColor)textFieldBackgroundColor { - return _backgroundColor; + return _textFieldBackgroundColor; } /*! @ignore */ @@ -1778,10 +1771,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [contentView setText:string]; [contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]]; - - if (_backgroundColor) - [contentView setBackgroundColor:_backgroundColor]; - [contentView setFont:[self currentValueForThemeAttribute:@"font"]]; [contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]]; [contentView setVerticalAlignment:[self currentValueForThemeAttribute:@"vertical-alignment"]]; @@ -1924,7 +1913,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", [self setDrawsBackground:[aCoder decodeBoolForKey:CPTextFieldDrawsBackgroundKey]]; - [self setBackgroundColor:[aCoder decodeObjectForKey:CPTextFieldBackgroundColorKey]]; + [self setTextFieldBackgroundColor:[aCoder decodeObjectForKey:CPTextFieldBackgroundColorKey]]; [self setLineBreakMode:[aCoder decodeIntForKey:CPTextFieldLineBreakModeKey]]; [self setAlignment:[aCoder decodeIntForKey:CPTextFieldAlignmentKey]]; @@ -1948,7 +1937,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", [aCoder encodeBool:_drawsBackground forKey:CPTextFieldDrawsBackgroundKey]; - [aCoder encodeObject:_backgroundColor forKey:CPTextFieldBackgroundColorKey]; + [aCoder encodeObject:_textFieldBackgroundColor forKey:CPTextFieldBackgroundColorKey]; [aCoder encodeInt:[self lineBreakMode] forKey:CPTextFieldLineBreakModeKey]; [aCoder encodeInt:[self alignment] forKey:CPTextFieldAlignmentKey]; diff --git a/Tests/Manual/CPTextField/AppController.j b/Tests/Manual/CPTextField/AppController.j index 629e9865b..52cbb591b 100644 --- a/Tests/Manual/CPTextField/AppController.j +++ b/Tests/Manual/CPTextField/AppController.j @@ -37,8 +37,7 @@ [contentView addSubview:textField]; var shadowLabel = [CPTextField labelWithTitle:@"This text should have a shadow."], - championOfLightLabel = [CPTextField labelWithTitle:@"This text should have no shadow."], - redLabel = [CPTextField labelWithTitle:@"This text should be white on a red background."]; + championOfLightLabel = [CPTextField labelWithTitle:@"This text should have no shadow."]; [shadowLabel setTextColor:[CPColor blackColor]]; [shadowLabel setTextShadowOffset:CGSizeMake(0, 1)]; @@ -48,16 +47,11 @@ [championOfLightLabel setTextShadowOffset:CGSizeMake(0, 1)]; [championOfLightLabel setTextShadowColor:[CPColor clearColor]]; - [redLabel setTextColor:[CPColor whiteColor]]; - [redLabel setBackgroundColor:[CPColor redColor]]; - [shadowLabel setFrame:CGRectMake(15, CGRectGetMaxY([textField frame]) + 10, 300, 18)]; [championOfLightLabel setFrame:CGRectMake(15, CGRectGetMaxY([shadowLabel frame]) + 2, 300, 18)]; - [redLabel setFrame:CGRectMake(15, CGRectGetMaxY([championOfLightLabel frame]) + 10, 300, 18)]; [contentView addSubview:shadowLabel]; [contentView addSubview:championOfLightLabel]; - [contentView addSubview:redLabel]; var jumpLabel = [CPTextField labelWithTitle:@"The text of these text fields should not move ('jump') when a field becomes the first responder. Labels on the right should replicate the input."];