From 3430349dd1b0d71d5e322484759d20dc81d3d7e6 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 25 Feb 2015 10:16:56 -0800 Subject: [PATCH] Fixed: CPApplication dispatch the event when having the auto complete menu of a CPTokenField opened Previously, the CPApplication dispatched the current event when having the auto complete menu of a CPTokenField opened. This occurs weird behavior. For instance when hitting enter on the menu and having a default button, the action of the button was triggered. Now, the CPTokenField handles the key enter when the autocomplete menu is opened. --- AppKit/CPTokenField.j | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index 705435aae..987f524cb 100644 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -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)