[OpenLayers-Commits] r11147 - in sandbox/elemoine/draw-feature:
lib/OpenLayers/Handler tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Sun Feb 20 09:42:58 EST 2011
Author: erilem
Date: 2011-02-20 06:42:58 -0800 (Sun, 20 Feb 2011)
New Revision: 11147
Modified:
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
sandbox/elemoine/draw-feature/tests/Handler/Path.html
Log:
handle this sequence correctly: finish geometry, mousedown holding shift key, mousemove holding shift key
Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js 2011-02-18 15:25:41 UTC (rev 11146)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js 2011-02-20 14:42:58 UTC (rev 11147)
@@ -227,7 +227,8 @@
var stopDown = this.stopDown;
if(this.freehandMode(evt)) {
stopDown = true;
- } else if(!this.lastDown || !this.lastDown.equals(evt.xy)) {
+ }
+ if(!this.lastDown || !this.lastDown.equals(evt.xy)) {
this.modifyFeature(evt.xy, !!this.lastUp);
}
this.mouseDown = true;
Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-18 15:25:41 UTC (rev 11146)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-20 14:42:58 UTC (rev 11147)
@@ -578,6 +578,67 @@
]), "geometry is correct");
}
+ // test for this sequence
+ // a) click
+ // b) dblclick
+ // c) mousedown holding shift key
+ // d) mousemove holding shift key
+ function test_freehand_sequence1(t) {
+ t.plan(2);
+ var map = new OpenLayers.Map("map", {
+ resolutions: [1]
+ });
+ var layer = new OpenLayers.Layer.Vector("foo", {
+ maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
+ isBaseLayer: true
+ });
+ map.addLayer(layer);
+ var control = new OpenLayers.Control({});
+ var handler = new OpenLayers.Handler.Path(control,
+ {done: function(g) { log.geometry = g; }},
+ {stopDown: false, stopUp: false}
+ );
+ control.handler = handler;
+ map.addControl(control);
+ map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+
+ handler.activate();
+ log = {};
+
+ // a) click on (0, 0)
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
+ handler.mouseup(
+ {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
+ // b) dblclick on (1, 1)
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
+ handler.mouseup(
+ {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
+ handler.dblclick(
+ {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
+ t.geom_eq(log.geometry,
+ new OpenLayers.Geometry.LineString([
+ new OpenLayers.Geometry.Point(-150, 75), // (0, 0)
+ new OpenLayers.Geometry.Point(-149, 74) // (1, 1)
+ ]), "geometry is correct after dblclick");
+ // c) mousedown holding shift key on (1, 1)
+ handler.mousedown(
+ {type: "mousedown", xy: new OpenLayers.Pixel(1, 1), shiftKey: true});
+ // d) mousemove holding shift key to (10, 10)
+ handler.mousemove(
+ {type: "mousemove", xy: new OpenLayers.Pixel(10, 10), shiftKey: true});
+ t.geom_eq(handler.line.geometry,
+ new OpenLayers.Geometry.LineString([
+ new OpenLayers.Geometry.Point(-149, 74), // (1, 1)
+ new OpenLayers.Geometry.Point(-140, 65) // (10, 10)
+ ]), "geometry is correct after mousemove");
+ }
+
function test_Handler_Path_destroy(t) {
t.plan(6);
var map = new OpenLayers.Map('map');
More information about the Commits
mailing list