diff --git a/AppKit/CPPanel.j b/AppKit/CPPanel.j index b9d5de37f..89a8f0355 100644 --- a/AppKit/CPPanel.j +++ b/AppKit/CPPanel.j @@ -126,10 +126,17 @@ CPDocModalWindowMask = 1 << 6; /*! @ignore */ -- (BOOL)_shouldCloseOnEscape +- (void)cancelOperation:(id)sender { - [self performClose:self]; - return YES; + if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]]) + return; + + [[self firstResponder] tryToPerform:@selector(cancel:) with:self]; +} + +- (void)cancel:(id)sender +{ + [self performClose:sender]; } @end diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 82b5d3a9a..0e074ccb1 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1795,7 +1795,7 @@ CPTexturedBackgroundWindowMask } return didTabBack; } - else if ([anEvent charactersIgnoringModifiers] === CPEscapeFunctionKey && [self _shouldCloseOnEscape]) + else if ([anEvent charactersIgnoringModifiers] == CPEscapeFunctionKey && [self _processKeyboardUIKey:anEvent]) { return; } @@ -3021,28 +3021,9 @@ CPTexturedBackgroundWindowMask if ([selectors count] <= 0) return NO; - if (character !== CPEscapeFunctionKey) - { - var selector = [selectors objectAtIndex:0]; - return [[self firstResponder] tryToPerform:selector with:self]; - } - else - { - /* - Cocoa sends complete: for the escape key (instead of the default cancelOperation:). This is also the only action that is not sent directly to the first responder, but through doCommandBySelector. The difference is that doCommandBySelector: will also send the action to the window and application delegates. - */ - [[self firstResponder] doCommandBySelector:@selector(complete:)]; - } + var selector = [selectors objectAtIndex:0]; - return NO; -} - -/*! - @ignore -*/ -- (BOOL)_shouldCloseOnEscape -{ - return NO; + return [[self firstResponder] tryToPerform:selector with:self]; } - (void)_dirtyKeyViewLoop diff --git a/AppKit/_CPPopoverWindow.j b/AppKit/_CPPopoverWindow.j index 1bb50cd1d..96870eeac 100644 --- a/AppKit/_CPPopoverWindow.j +++ b/AppKit/_CPPopoverWindow.j @@ -432,12 +432,18 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, /*! @ignore */ -- (BOOL)_shouldCloseOnEscape +- (void)cancelOperation:(id)sender +{ + if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]]) + return; + + [self cancel:self]; +} + +- (void)cancel:(id)sender { if (_closeOnBlur) - [[self delegate] performClose:self]; - - return YES; + [[self delegate] performClose:sender]; } /*!