more selection fixes
[potlatch2.git] / net / systemeD / potlatch2 / controller / DragWayNode.as
index 195547951059b8169a6a08db4beb4723871f7a42..abf22e8e076a4ad24dac7ab0db007024c68b6624 100644 (file)
@@ -8,6 +8,7 @@ package net.systemeD.potlatch2.controller {
         private var selectedWay:Way;
         private var draggingNode:Node;
         private var isDraggingStarted:Boolean = false;
+               private var isNew:Boolean = false;
 
         private var downX:Number;
         private var downY:Number;
@@ -16,11 +17,12 @@ package net.systemeD.potlatch2.controller {
                private const NOT_MOVED:uint=1;
                private const DRAGGING:uint=2;
         
-        public function DragWayNode(way:Way, node:Node, event:MouseEvent) {
+        public function DragWayNode(way:Way, node:Node, event:MouseEvent, newNode:Boolean) {
             selectedWay = way;
             draggingNode = node;
             downX = event.localX;
             downY = event.localY;
+                       isNew = newNode;
         }
  
        override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
@@ -30,13 +32,14 @@ package net.systemeD.potlatch2.controller {
                                        // mouse-up while dragging, so end drag
                        return new SelectedWayNode(selectedWay,draggingNode);
 //                     return endDrag();
-                               } else if (event.shiftKey) {
+                               } else if (event.shiftKey && !isNew) {
                                        // start new way
                                        var way:Way = controller.connection.createWay({}, [entity, entity]);
                                        return new DrawWay(way, true);
+                               } else if (event.shiftKey && isNew) {
+                       return new SelectedWayNode(selectedWay,draggingNode);
                                } else {
                                        // select node
-                                       Globals.vars.root.addDebug("- select node from DragWayNode");
                                        dragstate=NOT_DRAGGING;
                        return new SelectedWayNode(selectedWay,draggingNode);
                                }
@@ -72,10 +75,12 @@ package net.systemeD.potlatch2.controller {
                }
 
         override public function enterState():void {
-            controller.map.setHighlight(selectedWay, {showNodes: true } );
+            controller.map.setHighlight(selectedWay, { showNodes: true } );
+                       Globals.vars.root.addDebug("**** -> "+this);
         }
         override public function exitState():void {
-            controller.map.setHighlight(selectedWay, {showNodes: false } );
+            controller.map.setHighlight(selectedWay, { showNodes: false } );
+                       Globals.vars.root.addDebug("**** <- "+this);
         }
         override public function toString():String {
             return "DragWayNode";