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

Unified Diff: Source/web/WebInputEventFactoryMac.mm

Issue 788173002: Should set the modifiers for web mouse event on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed Created 6 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebInputEventFactoryMac.mm
diff --git a/Source/web/WebInputEventFactoryMac.mm b/Source/web/WebInputEventFactoryMac.mm
index e71b93ce071dfecab22ef8c652ff42fa0ca90142..07adba4b82d918e785ccfc136d67f55d47eae2fd 100644
--- a/Source/web/WebInputEventFactoryMac.mm
+++ b/Source/web/WebInputEventFactoryMac.mm
@@ -722,7 +722,18 @@ static inline int modifiersFromEvent(NSEvent* event) {
modifiers |= WebInputEvent::MetaKey;
if ([event modifierFlags] & NSAlphaShiftKeyMask)
modifiers |= WebInputEvent::CapsLockOn;
- // TODO(port): Set mouse button states
+
+ // The return value of 1 << 0 corresponds to the left mouse button,
+ // 1 << 1 corresponds to the right mouse button,
+ // 1 << n, n >= 2 correspond to other mouse buttons.
+ NSUInteger pressedButtons = [NSEvent pressedMouseButtons];
+
+ if (pressedButtons & (1 << 0))
+ modifiers |= WebInputEvent::LeftButtonDown;
+ if (pressedButtons & (1 << 1))
+ modifiers |= WebInputEvent::RightButtonDown;
+ if (pressedButtons & (1 << 2))
+ modifiers |= WebInputEvent::MiddleButtonDown;
return modifiers;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698