From 4a048657c57a01281e611079bea17fa92dbddddc Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 29 May 2010 03:10:39 -0400 Subject: [PATCH] If a button is named "Cancel" in a CPAlert window, give it the 'escape' key equivalent. --- AppKit/CPAlert.j | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index 97a2f1518..589a5d4ee 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -252,6 +252,9 @@ var CPAlertWarningImage, Buttons will be added starting from the right hand side of the \c CPAlert panel. The first button will have the index 0, the second button 1 and so on. + The first button will automatically be given a key equivalent of Return, + and any button titled "Cancel" will be given a key equivalent of Escape. + You really shouldn't need more than 3 buttons. */ - (void)addButtonWithTitle:(CPString)title @@ -271,6 +274,8 @@ var CPAlertWarningImage, if (_buttonCount == 0) [_alertPanel setDefaultButton:button]; + else if ([title lowercaseString] === "cancel") + [button setKeyEquivalent:CPEscapeKeyCode]; _buttonCount++; [_buttons addObject:button];