mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-07 17:38:02 +00:00
Token field 'keyUp:' support.
This commit is contained in:
1 parent
5683af9bc8
commit
132ac7c03f
1 file changed
+12
-28
+12
-28
@@ -45,8 +45,7 @@ var CPTokenFieldDOMInputElement = nil,
|
||||
CPTokenFieldCachedDragFunction = nil,
|
||||
CPTokenFieldFocusInput = NO,
|
||||
|
||||
CPTokenFieldBlurFunction = nil,
|
||||
CPTokenFieldKeyDownFunction = nil;
|
||||
CPTokenFieldBlurFunction = nil;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -608,19 +607,6 @@ var CPScrollDestinationNone = 0,
|
||||
return true;
|
||||
};
|
||||
|
||||
CPTokenFieldKeyUpFunction = function()
|
||||
{
|
||||
if ([CPTokenFieldInputOwner stringValue] !== CPTokenFieldTextDidChangeValue)
|
||||
{
|
||||
CPTokenFieldTextDidChangeValue = [CPTokenFieldInputOwner stringValue];
|
||||
[CPTokenFieldInputOwner textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:CPTokenFieldInputOwner userInfo:nil]];
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
};
|
||||
|
||||
CPTokenFieldHandleBlur = function(anEvent)
|
||||
{
|
||||
CPTokenFieldInputOwner = nil;
|
||||
@@ -628,15 +614,6 @@ var CPScrollDestinationNone = 0,
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
};
|
||||
|
||||
if (document.attachEvent)
|
||||
{
|
||||
CPTokenFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyUp, CPTokenFieldKeyUpFunction);
|
||||
}
|
||||
else
|
||||
{
|
||||
CPTokenFieldDOMInputElement.addEventListener(CPDOMEventKeyUp, CPTokenFieldKeyUpFunction, NO);
|
||||
}
|
||||
|
||||
//FIXME make this not onblur
|
||||
CPTokenFieldDOMInputElement.onblur = CPTokenFieldBlurFunction;
|
||||
|
||||
@@ -777,15 +754,22 @@ var CPScrollDestinationNone = 0,
|
||||
// Allow the input element to receive the event.
|
||||
if ([[self window] firstResponder] == self)
|
||||
{
|
||||
CPTokenFieldTextDidChangeValue = [CPTokenFieldInputOwner stringValue];
|
||||
// TODO if changed
|
||||
// [self _delayedShowCompletions];
|
||||
|
||||
CPTokenFieldTextDidChangeValue = [self stringValue];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyUp:(CPEvent)anEvent
|
||||
{
|
||||
if ([self stringValue] !== CPTokenFieldTextDidChangeValue)
|
||||
{
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
- (void)textDidChange:(CPNotification)aNotification
|
||||
{
|
||||
if ([aNotification object] !== self)
|
||||
|
||||
Reference in new issue
Block a user