[OpenLayers-Commits] r11072 - sandbox/elemoine/draw-feature/lib/OpenLayers/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Feb 9 09:55:27 EST 2011


Author: erilem
Date: 2011-02-09 06:55:27 -0800 (Wed, 09 Feb 2011)
New Revision: 11072

Modified:
   sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
Log:
Point Handler - remove the drawing property, check modifiers and for double-clicks in mouseup instead of mousedown

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js	2011-02-08 20:47:23 UTC (rev 11071)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js	2011-02-09 14:55:27 UTC (rev 11072)
@@ -11,9 +11,9 @@
 
 /**
  * Class: OpenLayers.Handler.Point
- * Handler to draw a point on the map.  Point is displayed on mouse down,
- *     moves on mouse move, and is finished on mouse up.  The handler triggers
- *     callbacks for 'done', 'cancel', and 'modify'.  The modify callback is
+ * Handler to draw a point on the map. Point is displayed on activation,
+ *     moves on mouse move, and is finished on mouse up. The handler triggers
+ *     callbacks for 'done', 'cancel', and 'modify'. The modify callback is
  *     called with each change in the sketch and will receive the latest point
  *     drawn.  Create a new instance with the <OpenLayers.Handler.Point>
  *     constructor.
@@ -43,12 +43,6 @@
     multi: false,
     
     /**
-     * Property: drawing 
-     * {Boolean} A point is being drawn
-     */
-    drawing: false,
-    
-    /**
      * Property: mouseDown
      * {Boolean} The mouse is down
      */
@@ -179,11 +173,7 @@
         if(!OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
             return false;
         }
-        // call the cancel callback if mid-drawing
-        if(this.drawing) {
-            this.cancel();
-        }
-        this.destroyFeature();
+        this.cancel();
         // If a layer's map property is set to null, it means that that layer
         // isn't added to the map. Since we ourself added the layer to the map
         // in activate(), we can assume that if this.layer.map is null it means
@@ -225,7 +215,9 @@
         if(cancel || !this.persist) {
             this.destroyFeature();
         }
-        this.createFeature();
+        if(!cancel) {
+            this.createFeature();
+        }
     },
 
     /**
@@ -332,17 +324,8 @@
      * {Boolean} Allow event propagation
      */
     mousedown: function(evt) {
-        // check keyboard modifiers
-        if(!this.checkModifiers(evt)) {
-            return true;
-        }
-        // ignore double-clicks
-        if(this.lastDown && this.lastDown.equals(evt.xy)) {
-            return true;
-        }
-        this.drawing = true;
-        this.modifyFeature(evt.xy);
         this.lastDown = evt.xy;
+        this.modifyFeature(evt.xy);
         return !this.stopDown;
     },
 
@@ -374,7 +357,16 @@
      * {Boolean} Allow event propagation
      */
     mouseup: function (evt) {
-        if(this.lastDown.equals(evt.xy)) {
+        // check keyboard modifiers
+        if(!this.checkModifiers(evt)) {
+            return true;
+        }
+        // ignore double-clicks
+        if(this.lastUp && this.lastUp.equals(evt.xy)) {
+            return true;
+        }
+        if(this.lastDown && this.lastDown.equals(evt.xy)) {
+            this.lastUp = evt.xy;
             this.finalize();
             return !this.stopUp;
         } else {



More information about the Commits mailing list