From 5ff9683cd761eeaf5d3f484b46ea04e0cb588e37 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Fri, 3 Sep 2010 10:18:26 -0700 Subject: [PATCH] Send the correct event when right-clicking in a focused text field --- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index 53b93dbe6..062f41254 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -1221,6 +1221,9 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; else if (type === "mousedown") { + var button = aDOMEvent.button; + _mouseDownIsRightClick = button == 2 || (button == 0 && modifierFlags & CPControlKeyMask); + if (sourceElement.tagName === "INPUT" && sourceElement != _DOMFocusElement) { if ([CPPlatform supportsDragAndDrop]) @@ -1233,11 +1236,11 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; _mouseIsDown = YES; //fake a down and up event so that event tracking mode will work correctly - [CPApp sendEvent:[CPEvent mouseEventWithType:CPLeftMouseDown location:location modifierFlags:modifierFlags + [CPApp sendEvent:[CPEvent mouseEventWithType:_mouseDownIsRightClick ? CPRightMouseDown : CPLeftMouseDown location:location modifierFlags:modifierFlags timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1 clickCount:CPDOMEventGetClickCount(_lastMouseDown, timestamp, location) pressure:0]]; - [CPApp sendEvent:[CPEvent mouseEventWithType:CPLeftMouseUp location:location modifierFlags:modifierFlags + [CPApp sendEvent:[CPEvent mouseEventWithType:_mouseDownIsRightClick ? CPRightMouseUp : CPLeftMouseUp location:location modifierFlags:modifierFlags timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1 clickCount:CPDOMEventGetClickCount(_lastMouseDown, timestamp, location) pressure:0]]; @@ -1249,9 +1252,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; _DOMBodyElement.style["-khtml-user-drag"] = "element"; } - var button = aDOMEvent.button; - _mouseDownIsRightClick = button == 2 || (button == 0 && modifierFlags & CPControlKeyMask); - StopContextMenuDOMEventPropagation = YES; event = _CPEventFromNativeMouseEvent(aDOMEvent, _mouseDownIsRightClick ? CPRightMouseDown : CPLeftMouseDown, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseDown, timestamp, location), 0);