[OpenLayers-Commits] r11079 - in sandbox/elemoine/draw-feature: lib/OpenLayers/Handler tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Feb 10 05:45:35 EST 2011


Author: erilem
Date: 2011-02-10 02:45:35 -0800 (Thu, 10 Feb 2011)
New Revision: 11079

Modified:
   sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
   sandbox/elemoine/draw-feature/tests/Handler/Path.html
Log:
path handler - watch double mousedowns

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js	2011-02-10 10:45:25 UTC (rev 11078)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js	2011-02-10 10:45:35 UTC (rev 11079)
@@ -215,6 +215,12 @@
      * {Boolean} Allow event propagation
      */
     mousedown: function(evt) {
+        // consecutive mousedowns at the same location are
+        // ignored, this occurs when finalizing the line on
+        // dlbclick
+        if (this.lastDown && this.lastDown.equals(evt.xy)) {
+            return false;
+        }
         this.mouseDown = true;
         this.lastDown = evt.xy;
         this.modifyFeature(evt.xy);
@@ -257,7 +263,8 @@
      * {Boolean} Allow event propagation
      */
     mouseup: function (evt) {
-        // ignore double-clicks
+        // consecutive mouseups at the same location must not
+        // cause adding new points to the line
         if (this.lastUp && this.lastUp.equals(evt.xy)) {
             return false;
         }

Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html	2011-02-10 10:45:25 UTC (rev 11078)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html	2011-02-10 10:45:35 UTC (rev 11079)
@@ -209,33 +209,33 @@
         // mouse down ("modify")
         handler.mousedown({type: "mousedown",
                            xy: new OpenLayers.Pixel(10, 10)});
-        t.eq(log.length, 10, "[mousedown] called back");
+        t.eq(log.length, 9, "[mousedown] not called back");
         // mouse up ("point", "modify")
         handler.mouseup({type: "mouseup",
                          xy: new OpenLayers.Pixel(10, 10)});
-        t.eq(log.length, 10, "[mouseup] not called back");
+        t.eq(log.length, 9, "[mouseup] not called back");
         // double click
         handler.dblclick({type: "dblclick",
                           xy: new OpenLayers.Pixel(10, 10)});
-        t.eq(log.length, 12, "[dblclick] called back");
-        t.eq(log[10].type, "done", "[dblclick] done called");
-        t.geom_eq(log[10].args[0],
+        t.eq(log.length, 11, "[dblclick] called back twice");
+        t.eq(log[9].type, "done", "[dblclick] done called");
+        t.geom_eq(log[9].args[0],
             new OpenLayers.Geometry.LineString([
                 new OpenLayers.Geometry.Point(-150, 75),
                 new OpenLayers.Geometry.Point(-140, 65)
             ]),
             "[dblclick] correct linestring"
         );
-        t.eq(log[11].type, "create", "[dblclick] create called");
-        t.geom_eq(log[11].args[0], new OpenLayers.Geometry.Point(-200, 125),
+        t.eq(log[10].type, "create", "[dblclick] create called");
+        t.geom_eq(log[10].args[0], new OpenLayers.Geometry.Point(-200, 125),
                   "[dblclick] correct point");
-        t.ok(log[11].args[1] == handler.line,
+        t.ok(log[10].args[1] == handler.line,
              "[dblclick] correct feature");
         // cancel
         handler.cancel();
-        t.eq(log.length, 13, "[cancel] called back");
-        t.eq(log[12].type, "cancel", "[cancel] canced called");
-        t.geom_eq(log[12].args[0],
+        t.eq(log.length, 12, "[cancel] called back");
+        t.eq(log[11].type, "cancel", "[cancel] canced called");
+        t.geom_eq(log[11].args[0],
             new OpenLayers.Geometry.LineString([
                 new OpenLayers.Geometry.Point(-200, 125)
             ]),



More information about the Commits mailing list