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; |
} |