Don't allow parallelise keypress to return 0-length ways
[potlatch2.git] / net / systemeD / potlatch2 / controller / SelectedParallelWay.as
index cd3044647cab0f0020a852e6580bae8b9eea02ab..8ff494c41c8364e7cae4befb5f8fa69d029ff375 100644 (file)
@@ -4,7 +4,6 @@ package net.systemeD.potlatch2.controller {
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.halcyon.Map;
        import net.systemeD.potlatch2.tools.Parallelise;
-       import net.systemeD.halcyon.Globals;
 
     /** The state midway during the use of the "parallelise tool", where a parallel way has been created but is stuck to the 
     * mouse cursor, allowing the user to choose how far from the original way it should go. This transforms it in the process. */
@@ -22,11 +21,12 @@ package net.systemeD.potlatch2.controller {
         }
 
         override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
-                       if (event.type==MouseEvent.MOUSE_MOVE) {
+                       if (event.type==MouseEvent.MOUSE_MOVE || event.type==MouseEvent.MOUSE_UP) {
                                var lon:Number =controller.map.coord2lon(controller.map.mouseX);
                                var latp:Number=controller.map.coord2latp(controller.map.mouseY);
                                parallelise.draw(distanceFromWay(lon,latp));
-                       } else if (event.type==MouseEvent.MOUSE_UP) {
+                       }
+                       if (event.type==MouseEvent.MOUSE_UP) {
                                return new SelectedWay(firstSelected as Way);
                        }
                        return this;
@@ -77,15 +77,13 @@ package net.systemeD.potlatch2.controller {
                /** Creates the WayUI for the parallel way. */
                override public function enterState():void {
                        selection=[parallelise.parallelWay];
-                       controller.map.paint.createWayUI(firstSelected as Way);
+                       layer.createWayUI(firstSelected as Way);
                        startlon =controller.map.coord2lon(controller.map.mouseX);
                        startlatp=controller.map.coord2latp(controller.map.mouseY);
-                       Globals.vars.root.addDebug("**** -> "+this);
         }
                /** Unselects. */
                override public function exitState(newState:ControllerState):void {
             clearSelection(newState);
-                       Globals.vars.root.addDebug("**** <- "+this);
         }
 
         override public function toString():String {