incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r533196 - /incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js
Date Fri, 27 Apr 2007 19:29:29 GMT
Author: jmargaris
Date: Fri Apr 27 12:29:29 2007
New Revision: 533196

URL: http://svn.apache.org/viewvc?view=rev&rev=533196
Log:
For David Gennaco: https://issues.apache.org/jira/browse/XAP-389

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js?view=diff&rev=533196&r1=533195&r2=533196
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js Fri Apr 27
12:29:29 2007
@@ -1203,12 +1203,19 @@
 	            return;
 	        }
 	        
-	    	var targetAncestor = e.relatedTarget.parentNode;
-	    	while (targetAncestor != null) { // TODO can this be optimized somehow?
-	    		if (targetAncestor === e.currentTarget) {
-	    			return; // ITS MOVING OUT OF US, BUT INTO OUR PROGENY, SO NOT REALLY OUT!
-	    		}
-	    		targetAncestor = targetAncestor.parentNode;
+	        try {
+	    	    var targetAncestor = e.relatedTarget.parentNode;
+	    	    while (targetAncestor != null) { // TODO can this be optimized somehow?
+	    		    if (targetAncestor === e.currentTarget) {
+	    			    return; // ITS MOVING OUT OF US, BUT INTO OUR PROGENY, SO NOT REALLY OUT!
+	    		    }
+	    		    targetAncestor = targetAncestor.parentNode;
+	    	    }
+	    	} catch (error) {
+	    	    // firefox can throw security exceptions when attemptin to access
+	    	    // the parent node of the related target, for instance, when it is
+	    	    // an input field, we'll just have to assume we're truly mousing out
+	    	    targetAncestor = null;  
 	    	}
 	    }
 		     
@@ -1278,6 +1285,30 @@
     }
 }
 
+xap.bridges.basic.AbstractWidgetBridge.prototype.getMouseButtonNumber = function(htmlEvent)
{
+    var buttonNumber = null;
+    var browserButtonCode = htmlEvent.button;
+    if (typeof browserButtonCode != "undefined") {
+        // we use 1 left, 2 right, 3 middle 
+        if(dojo.render.html.ie) {
+            if (browserButtonCode == 4) {  // MSIE: 1 left, 2 right, 4 middle
+                buttonNumber = 3;
+            } else {
+                buttonNumber = browserButtonCode;
+            }
+        } else { // W3C: 0 left, 1 middle, 2 right
+            if (browserButtonCode == 0) {
+                buttonNumber = 1;
+            } else if (browserButtonCode == 1) {
+                buttonNumber = 3;
+            } else {
+                buttonNumber = browserButtonCode;
+            }
+        }
+    }
+    return buttonNumber;
+}
+
 xap.bridges.basic.AbstractWidgetBridge.prototype.fireMouseEvent = function( eventName, htmlEvent){
     // optimization, check whether there is an event handler registered and exit fast first
     if (!this.getElement().getAttribute(eventName)) {
@@ -1290,12 +1321,10 @@
 	//relative to current component, this seems right in IE and moz
 	clientEvent.clickX = htmlEvent.layerX;
 	clientEvent.clickY = htmlEvent.layerY;
-	clientEvent.buttonNumber = htmlEvent.button;
+	clientEvent.buttonNumber = this.getMouseButtonNumber(htmlEvent);
 	this._addKeyMods(clientEvent, htmlEvent);
 	
 	this.fireEvent(eventName,null,null,clientEvent);
-	//IMPORTANT button number is 0-2 based, not 1-3?
-	//depends on browser, need to fix this up...
 	//IMPORTANT consumed, cancel?
 }
 



Mime
View raw message