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

Unified Diff: chrome/browser/ui/cocoa/event_utils.mm

Issue 6893046: added CTRL+Click and SHIFT+Click handler for context menu, Back and Forward. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: make this patch applicable to the latest trunk Created 9 years, 6 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 | « chrome/browser/ui/cocoa/event_utils.h ('k') | chrome/browser/ui/cocoa/event_utils_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/event_utils.mm
diff --git a/chrome/browser/ui/cocoa/event_utils.mm b/chrome/browser/ui/cocoa/event_utils.mm
index 32ad8f80c649cc2995b0335adc66fd225b714a37..5b7723225c172e0cd850a56cb3314471c33cffc5 100644
--- a/chrome/browser/ui/cocoa/event_utils.mm
+++ b/chrome/browser/ui/cocoa/event_utils.mm
@@ -5,9 +5,53 @@
#import "chrome/browser/ui/cocoa/event_utils.h"
#include "content/browser/disposition_utils.h"
+#include "ui/base/events.h"
+
+namespace {
+ bool isLeftButtonEvent(NSEvent* event) {
+ NSEventType type = [event type];
+ return type == NSLeftMouseDown ||
+ type == NSLeftMouseDragged ||
+ type == NSLeftMouseUp;
+ }
+
+ bool isRightButtonEvent(NSEvent* event) {
+ NSEventType type = [event type];
+ return type == NSRightMouseDown ||
+ type == NSRightMouseDragged ||
+ type == NSRightMouseUp;
+ }
+
+ bool isMiddleButtonEvent(NSEvent* event) {
+ if ([event buttonNumber] != 2)
+ return false;
+
+ NSEventType type = [event type];
+ return type == NSOtherMouseDown ||
+ type == NSOtherMouseDragged ||
+ type == NSOtherMouseUp;
+ }
+}
namespace event_utils {
+// Retrieves a bitsum of ui::EventFlags from NSEvent.
+int EventFlagsFromNSEvent(NSEvent* event) {
+ NSUInteger modifiers = [event modifierFlags];
+
+ int flags = 0;
+ flags |= (modifiers & NSAlphaShiftKeyMask) ? ui::EF_CAPS_LOCK_DOWN : 0;
+ flags |= (modifiers & NSShiftKeyMask) ? ui::EF_SHIFT_DOWN : 0;
+ flags |= (modifiers & NSControlKeyMask) ? ui::EF_CONTROL_DOWN : 0;
+ flags |= (modifiers & NSAlternateKeyMask) ? ui::EF_ALT_DOWN : 0;
+ flags |= (modifiers & NSCommandKeyMask) ? ui::EF_COMMAND_DOWN : 0;
+ flags |= isLeftButtonEvent(event) ? ui::EF_LEFT_BUTTON_DOWN : 0;
+ flags |= isRightButtonEvent(event) ? ui::EF_RIGHT_BUTTON_DOWN : 0;
+ flags |= isMiddleButtonEvent(event) ? ui::EF_MIDDLE_BUTTON_DOWN : 0;
+ return flags;
+}
+
+
WindowOpenDisposition WindowOpenDispositionFromNSEvent(NSEvent* event) {
NSUInteger modifiers = [event modifierFlags];
return WindowOpenDispositionFromNSEventWithFlags(event, modifiers);
« no previous file with comments | « chrome/browser/ui/cocoa/event_utils.h ('k') | chrome/browser/ui/cocoa/event_utils_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698