summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 22:37:10 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 22:37:10 +0000
commitc51e6b955efef19073972efa5a1bd75701dfc6d4 (patch)
tree593df2d7dbd1235db6f7812b6f2d19fb096e39c6
parent0788801b4b81208446c0b9973b50dff0312f3f9b (diff)
downloadchromium_src-c51e6b955efef19073972efa5a1bd75701dfc6d4.zip
chromium_src-c51e6b955efef19073972efa5a1bd75701dfc6d4.tar.gz
chromium_src-c51e6b955efef19073972efa5a1bd75701dfc6d4.tar.bz2
Implemented Esc/Command-. shortcuts for HTML dialogs.
BUG=32216 TEST=manually Review URL: http://codereview.chromium.org/548051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36800 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller.mm20
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/html_dialog_window_controller.mm b/chrome/browser/cocoa/html_dialog_window_controller.mm
index 5e65420..ab13e52 100644
--- a/chrome/browser/cocoa/html_dialog_window_controller.mm
+++ b/chrome/browser/cocoa/html_dialog_window_controller.mm
@@ -5,6 +5,7 @@
#import "chrome/browser/cocoa/html_dialog_window_controller.h"
#include "base/gfx/size.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/scoped_nsobject.h"
#include "base/sys_string_conversions.h"
@@ -177,6 +178,25 @@ void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent(
if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char)
return;
+ // Close ourselves if the user hits Esc or Command-. . The normal
+ // way to do this is to implement (void)cancel:(int)sender, but
+ // since we handle keyboard events ourselves we can't do that.
+ //
+ // According to experiments, hitting Esc works regardless of the
+ // presence of other modifiers (as long as it's not an app-level
+ // shortcut, e.g. Commmand-Esc for Front Row) but no other modifiers
+ // can be present for Command-. to work.
+ //
+ // TODO(thakis): It would be nice to get cancel: to work somehow.
+ // Bug: http://code.google.com/p/chromium/issues/detail?id=32828 .
+ if (event.type == NativeWebKeyboardEvent::RawKeyDown &&
+ ((event.windowsKeyCode == base::VKEY_ESCAPE) ||
+ (event.windowsKeyCode == base::VKEY_OEM_PERIOD &&
+ event.modifiers == NativeWebKeyboardEvent::MetaKey))) {
+ [controller_ close];
+ return;
+ }
+
ChromeEventProcessingWindow* event_window =
static_cast<ChromeEventProcessingWindow*>([controller_ window]);