[Commits] r202 - sandbox/opengeo/drake/trunk/apps/drake

commits at geoext.org commits at geoext.org
Thu Feb 19 17:49:32 CET 2009


Author: tcoulter
Date: 2009-02-19 17:49:31 +0100 (Thu, 19 Feb 2009)
New Revision: 202

Modified:
   sandbox/opengeo/drake/trunk/apps/drake/LayerNodeUI.js
Log:
Trying to solve ticket #44 (http://projects.opengeo.org/geoext/ticket/44). This seems to in Firefox, though I suspect we might have trouble in other browsers. This needs to be tested.

Modified: sandbox/opengeo/drake/trunk/apps/drake/LayerNodeUI.js
===================================================================
--- sandbox/opengeo/drake/trunk/apps/drake/LayerNodeUI.js	2009-02-18 21:56:15 UTC (rev 201)
+++ sandbox/opengeo/drake/trunk/apps/drake/LayerNodeUI.js	2009-02-19 16:49:31 UTC (rev 202)
@@ -35,13 +35,32 @@
             
             // If there's no first item... because of the functionality above, this is 
             // equivalent to saying if (this.note.attributes.queryable == true) {...}.
-            if (this.queryCol.first()) {
-                this.queryCol.first().on("click", function(evt, target, parameters){
-                    this.node.ownerTree.fireEvent("layeractivated", this.node.layer);
+            var div = this.queryCol.first();
+            if (div) {
+                div.on("click", function(evt, target, parameters){
+                    
+                    // Note: target.click() below somehow causes the div's click event
+                    // to be fired again. In total, then, the user clicking on the radio
+                    // button would cause the layeractivated event to be fired twice -- we
+                    // don't want. To distinguish between the user-generated click and the
+                    // and the artificially generated click (i.e., target.click()), we check
+                    // the browser events "isTrusted" parameter to see which click we're
+                    // responding to. If "isTrusted" is true, then this event is the original
+                    // event fired by the browser, and not the one fired by target.click().
+                    //
+                    // Oddly, due to the radio button already being clicked, target.click() 
+                    // must not keep firing the click event, or else this function cause an
+                    // infinite loop.
+                    if (evt.browserEvent.isTrusted == true) {
+                        this.node.ownerTree.fireEvent("layeractivated", this.node.layer);
+                    }
+                    
                     target.click();
+                    
                     return true;
                 }, this);
             }
+            
             this.queryCol.addClass("gx-tree-query-col");
 
             this.clearEl = Ext.get(this.elNode).insertHtml("beforeEnd", "<div class='x-clear'></div>", true);



More information about the Commits mailing list