remove node from this way only, and some fixes
[potlatch2.git] / net / systemeD / potlatch2 / controller / ControllerState.as
index 8d586ec59348b1129c0ebecca32168aec1ca641c..23946f433ae37915d7bed52d54fccf830c895a6c 100644 (file)
@@ -59,12 +59,12 @@ package net.systemeD.potlatch2.controller {
                                } else if ( focus is Node ) {
                                        // select POI node
                                        return new DragPOINode(entity as Node,event,false);
-//                             } else if ( entity is Node && selectedWay && entity.hasParent(selectedWay) ) {
-//                                     // select node within this way
-//                  return new DragWayNode(selectedWay, Node(entity), event, false);
+                               } else if ( entity is Node && selectedWay && entity.hasParent(selectedWay) ) {
+                                       // select node within this way
+                       return new DragWayNode(selectedWay,  getNodeIndex(selectedWay,entity as Node),  event, false);
                                } else if ( entity is Node && focus is Way ) {
                                        // select way node
-                                       return new DragWayNode(focus as Way,entity as Node,event,false);
+                                       return new DragWayNode(focus as Way, getNodeIndex(focus as Way,entity as Node), event, false);
                                }
                        } else if ( event.type == MouseEvent.MOUSE_UP && focus == null && map.dragstate!=map.DRAGGING ) {
                                return new NoSelection();
@@ -97,6 +97,13 @@ package net.systemeD.potlatch2.controller {
                        return null;
                }
                
+               protected function getNodeIndex(way:Way,node:Node):uint {
+                       for (var i:uint=0; i<way.length; i++) {
+                               if (way.getNode(i)==node) { return i; }
+                       }
+                       return null;
+               }
+               
 
     }
 }