From eefec02de4bcda8ee0a653ade8ae3a61ee08b830 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Wed, 30 Jan 2013 18:15:42 +0800 Subject: [PATCH] Fixed tracking event listener test to actually look for tracking events, fixed some method documentation --- AppKit/CPApplication.j | 20 +++++++++++--------- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 13 ++++++++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index ebf440b6d..cfab103f2 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -915,11 +915,12 @@ CPRunContinuesResponse = -1002; /*! Fires a callback function when an event matching a given mask occurs. - @param aCallback - A js function to be fired. - @prarm aMask - An event mask for the next event. - @param anExpiration - The date for which this callback expires (not implemented). + @param aCallback A js function to be fired. + @prarm aMask An event mask for the next event. + @param anExpiration The date for which this callback expires (not implemented). @param inMode (not implemented). - @param shouldDequeue (not implemented). + @param shouldDequeue YES to remove the event from the queue after calling the callback, + NO to deliver it normally. */ - (void)setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue { @@ -930,12 +931,13 @@ CPRunContinuesResponse = -1002; Assigns a target and action for the next event matching a given event mask. The callback method called will be passed the CPEvent when it fires. - @param aTarget - The target object for the callback. - @param aSelector - The selector which should be called on the target object. - @param aMask - The mask for a given event which should trigger the callback. - @param anExpiration - The date for which the callback expires (not implemented). + @param aTarget The target object for the callback. + @param aSelector The selector which should be called on the target object. + @param aMask The mask for a given event which should trigger the callback. + @param anExpiration The date for which the callback expires (not implemented). @param aMode (not implemented). - @param shouldDequeue (not implemented). + @param shouldDequeue YES to remove the event from the queue after calling the callback, + NO to deliver it normally. */ - (void)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue { diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index ae91f7f5c..4e6e9e66f 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -318,7 +318,8 @@ var resizeTimer = nil; // Make sure the pastboard element is blurred. _DOMPasteboardElement.blur(); - // Create a full screen div to protect against iframes and other elements from consuming events during tracking + // Create a full screen div to protect against iframes and other elements + // from consuming events during tracking // FIXME: multiple windows _DOMEventGuard = theDocument.createElement("div"); _DOMEventGuard.style.position = "absolute"; @@ -1275,7 +1276,7 @@ var resizeTimer = nil; _DOMEventMode = YES; _mouseIsDown = YES; - //fake a down and up event so that event tracking mode will work correctly + // Fake a down and up event so that event tracking mode will work correctly [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]]; @@ -1322,13 +1323,15 @@ var resizeTimer = nil; if (StopDOMEventPropagation && (!supportsNativeDragAndDrop || type !== "mousedown" && !isDragging)) CPDOMEventStop(aDOMEvent, self); - // if there are any tracking event listeners then show the event guard so we don't lose events to iframes - // TODO Actually check for tracking event listeners, not just any listener but _CPRunModalLoop. + // If there are any tracking event listeners (listening for CPLeftMouseDraggedMask) + // then show the event guard so we don't lose events to iframes var hasTrackingEventListener = NO; for (var i = 0; i < CPApp._eventListeners.length; i++) { - if (CPApp._eventListeners[i]._callback !== _CPRunModalLoop) + var listener = CPApp._eventListeners[i]; + + if (listener._callback !== _CPRunModalLoop && (listener._mask & CPLeftMouseDraggedMask)) { hasTrackingEventListener = YES; break;