[OpenLayers-Commits] r11226 - in trunk/openlayers: lib/OpenLayers/Handler tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Feb 22 06:21:20 EST 2011


Author: bartvde
Date: 2011-02-22 03:21:20 -0800 (Tue, 22 Feb 2011)
New Revision: 11226

Modified:
   trunk/openlayers/lib/OpenLayers/Handler/Click.js
   trunk/openlayers/tests/Handler/Click.html
Log:
fix up issue with Sencha Touch example not handling double tap to zoom in, r=elemoine (closes #3079)

Modified: trunk/openlayers/lib/OpenLayers/Handler/Click.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Handler/Click.js	2011-02-22 11:10:35 UTC (rev 11225)
+++ trunk/openlayers/lib/OpenLayers/Handler/Click.js	2011-02-22 11:21:20 UTC (rev 11226)
@@ -97,6 +97,12 @@
     last: null,
 
     /**
+     * Property: touch
+     * {Boolean} Are we on a touch enabled device? Default is false.
+     */
+    touch: false,
+
+    /**
      * Property: rightclickTimerId
      * {Number} The id of the right mouse timeout waiting to clear the 
      *     <delayedEvent>.
@@ -148,6 +154,7 @@
      * {Boolean} Continue propagating this event.
      */
     touchstart: function(evt) {
+        this.touch = true;
         this.down = evt;
         this.last = null;
         return true;
@@ -279,6 +286,10 @@
      * {Boolean} Continue propagating this event.
      */
     click: function(evt) {
+        // Sencha Touch emulates click events, see ticket 3079 for more info
+        if (this.touch === true && evt.type === "click") {
+            return !this.stopSingle;
+        }
         if(this.passesTolerance(evt)) {
             if(this.timerId != null) {
                 // already received a click

Modified: trunk/openlayers/tests/Handler/Click.html
===================================================================
--- trunk/openlayers/tests/Handler/Click.html	2011-02-22 11:10:35 UTC (rev 11225)
+++ trunk/openlayers/tests/Handler/Click.html	2011-02-22 11:21:20 UTC (rev 11226)
@@ -329,6 +329,43 @@
         });
     }
 
+    function test_touch_ignoresimulatedclick(t) {
+        t.plan(2);
+
+        // set up
+
+        var log;
+
+        var map = new OpenLayers.Map('map');
+        var control = {map: map};
+
+        var callbacks = {
+            'dblclick': function(e) {
+                log.dblclick = {x: e.xy.x, y: e.xy.y,
+                   lastTouches: e.lastTouches};
+            }
+        };
+
+        var handler = new OpenLayers.Handler.Click(
+                control, callbacks,
+                {'double': true, pixelTolerance: null});
+
+        // test
+
+        log = {};
+        handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
+        handler.touchend({});
+        handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
+        handler.touchend({type: "click"});
+
+        t.eq(handler.touch, true, "Touch property should be true");
+        
+        t.ok(log.dblclick == undefined, "dblclick callback not called with simulated click");
+
+        // tear down
+        map.destroy();
+    }
+
     function test_touch_dblclick(t) {
         t.plan(5);
 



More information about the Commits mailing list