Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1647)

Unified Diff: chrome/browser/chrome_application_mac.mm

Issue 271054: Send key equivalents to renderer first, sendEvent-based. (Closed)
Patch Set: speling Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/chrome_browser_window.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_application_mac.mm
diff --git a/chrome/browser/chrome_application_mac.mm b/chrome/browser/chrome_application_mac.mm
index a94d3aac93e1ead66cf62586da73bee921eae574..456ba3533b74d6ad838c7de42bd0c20f045fc10d 100644
--- a/chrome/browser/chrome_application_mac.mm
+++ b/chrome/browser/chrome_application_mac.mm
@@ -4,6 +4,8 @@
#import "chrome/browser/chrome_application_mac.h"
+#import "chrome/browser/renderer_host/render_widget_host_view_mac.h"
+
@implementation CrApplication
// -terminate: is the entry point for orderly "quit" operations in Cocoa.
@@ -83,4 +85,25 @@
return [super sendAction:anAction to:aTarget from:sender];
}
+- (void)sendEvent:(NSEvent*)event {
+ // The superclass's |sendEvent:| sends keyboard events to the menu before
+ // dispatching them to |keyDown:|. Since we want to send keys to the renderer
+ // before sending them to the menu, change this behavior.
+ if ([event type] == NSKeyDown || [event type] == NSKeyUp) {
+ if ([[[self keyWindow] firstResponder]
+ isKindOfClass:[RenderWidgetHostViewCocoa class]]) {
+
+ // No other mac browser sends keyup() for keyboard equivalents, so let's
+ // suppress this.
+ if (([event modifierFlags] & NSCommandKeyMask) && [event type] == NSKeyUp)
+ return;
+
+ [[self keyWindow] sendEvent:event];
+ return;
+ }
+ }
+
+ [super sendEvent:event];
+}
+
@end
« no previous file with comments | « no previous file | chrome/browser/cocoa/chrome_browser_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698