Merge pull request #2319 from Dogild/TokenFieldkeyEquivalent

Fixed: CPApplication dispatch the event when having the auto complete menu of a CPTokenField opened
This commit is contained in:
Antoine Mercadal
2015-02-25 11:34:44 -08:00
+15
View File
@@ -1033,6 +1033,21 @@ CPTokenFieldDeleteButtonType = 1;
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
- (BOOL)performKeyEquivalent:(CPEvent)anEvent
{
var characters = [anEvent characters];
// Here we handle the event when getting a CPNewlineCharacter or CPCarriageReturnCharacter when the menu is open
// We don't want that the application dispatches the event to the other controls
if ([self hasThemeState:CPThemeStateAutocompleting] && (characters === CPNewlineCharacter || characters === CPCarriageReturnCharacter))
{
[self keyDown:anEvent];
return YES;
}
return [super performKeyEquivalent:anEvent];
}
- (void)textDidChange:(CPNotification)aNotification
{
if ([aNotification object] !== self)