fix creating ways duplicate node bug, and connecting to existing way-node bug
[potlatch2.git] / net / systemeD / potlatch2 / controller / DrawWay.as
index 934822b010699605d5a0c6e43c347dca67eee4bd..9932cfb3f286c1c15f21e556c8b418b2b8db2d8c 100644 (file)
@@ -18,16 +18,17 @@ package net.systemeD.potlatch2.controller {
                override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
                        var mouse:Point;
                        var node:Node;
-                       var focus:Entity = NoSelection.getTopLevelFocusEntity(entity);
-                       if ( event.type == MouseEvent.CLICK ) {
-                               if ( focus == null ) {
+
+                       if ( event.type == MouseEvent.MOUSE_UP ) {
+                               if ( entity == null ) {
                                        node = createAndAddNode(event);
                                        resetElastic(node);
-                               } else if ( focus is Node ) {
-                                       appendNode(focus as Node);
-                               } else if ( focus is Way ) {
+                               } else if ( entity is Node ) {
+                                       appendNode(entity as Node);
+                                       resetElastic(entity as Node);
+                               } else if ( entity is Way ) {
                                        node = createAndAddNode(event);
-                                       Way(focus).insertNodeAtClosestPosition(node, true);
+                                       Way(entity).insertNodeAtClosestPosition(node, true);
                                        resetElastic(node);
                                }
                        } else if ( event.type == MouseEvent.MOUSE_MOVE ) {