mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 22:51:28 +00:00
Fixed a bug where placeholder state was not updated correctly.
Reviewed by me.
This commit is contained in:
committed by
Ross Boucher
parent
db6c70215a
commit
d0399eb902
+19
-8
@@ -445,6 +445,9 @@ CPTextFieldStatePlaceholder = 1 << 13;
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
_controlState |= CPControlStateEditing;
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
@@ -487,6 +490,9 @@ CPTextFieldStatePlaceholder = 1 << 13;
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
_controlState &= ~CPControlStateEditing;
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
@@ -538,19 +544,24 @@ CPTextFieldStatePlaceholder = 1 << 13;
|
||||
{
|
||||
[super setObjectValue:aValue];
|
||||
|
||||
/*
|
||||
#if PLATFORM(DOM)
|
||||
if ([[self window] firstResponder] == self)
|
||||
[[self class] _inputElement].value = displayString;
|
||||
#endif
|
||||
*/
|
||||
[self _updatePlaceholderState];
|
||||
}
|
||||
|
||||
var string = [self stringValue];
|
||||
- (void)_updatePlaceholderState
|
||||
{
|
||||
var string = [self stringValue],
|
||||
controlState = _controlState;
|
||||
|
||||
if (!string || [string length] === 0)
|
||||
if ((!string || [string length] === 0) && !(_controlState & CPControlStateEditing))
|
||||
_controlState |= CPTextFieldStatePlaceholder;
|
||||
else
|
||||
_controlState &= ~CPTextFieldStatePlaceholder;
|
||||
|
||||
if (_controlState !== controlState)
|
||||
{
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user