diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index e8ab8adfb..3f98b9a77 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -80,6 +80,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting", CPEvent _mouseDownEvent; BOOL _preventResign; + BOOL _shouldNotifyTarget; } + (CPCharacterSet)defaultTokenizingCharacterSet @@ -209,10 +210,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting", [self _inputElement].value = @""; [self setNeedsLayout]; - var theBinding = [CPKeyValueBinding getBinding:CPValueBinding forObject:self]; - - if (theBinding) - [theBinding reverseSetValueFor:@"objectValue"]; + [self _controlTextDidChange]; } - (void)_autocomplete @@ -272,6 +270,8 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting", [theBinding reverseSetValueFor:@"objectValue"]; [self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]]; + + _shouldNotifyTarget = YES; } - (void)_removeSelectedTokens:(id)sender @@ -402,7 +402,14 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting", [self setNeedsLayout]; - [self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]]; + if (_shouldNotifyTarget) + { + _shouldNotifyTarget = NO; + [self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]]; + + if ([self sendsActionOnEndEditing]) + [self sendAction:[self action] to:[self target]]; + } return YES; } @@ -555,6 +562,12 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting", [self setNeedsDisplay:YES]; } +- (void)sendAction:(SEL)anAction to:(id)anObject +{ + _shouldNotifyTarget = NO; + [super sendAction:anAction to:anObject]; +} + // Incredible hack to disable supers implementation // so it cannot change our object value and break the tokenfield - (void)_setStringValue:(id)aValue