Listen for changes to the way nodes, and update the elastic. Fixes another undo/redo...
authorAndy Allan <gravitystorm@gmail.com>
Thu, 26 Aug 2010 15:52:18 +0000 (15:52 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Thu, 26 Aug 2010 15:52:18 +0000 (15:52 +0000)
TODO.txt
net/systemeD/potlatch2/controller/DrawWay.as

index de462a0..0eac6e1 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -35,7 +35,6 @@ Potlatch 2: main outstanding issues
 * B keypress for background source tag
 * Multiple selection
 * Options should be remembered via SharedObjects
-* When drawing a way, undo (via keypress) after backspaceNode doesn't update the elastic
 * small node hitzone when creating areas - hitzone and mouseover UI don't match up
 * backspaceNode leaves junctions on other ways highlighted
 * Unexpected number of undo actions (3) when undoing drawway after adding a junction
index a115d86..801bc81 100644 (file)
@@ -29,6 +29,8 @@ package net.systemeD.potlatch2.controller {
                                lastClick=way.getNode(0);
                                lastClickTime=new Date();
                        }
+            way.addEventListener(Connection.WAY_NODE_REMOVED, fixElastic);
+            way.addEventListener(Connection.WAY_NODE_ADDED, fixElastic);
                }
                
                override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
@@ -130,6 +132,19 @@ package net.systemeD.potlatch2.controller {
                        elastic.end = mouse;
                }
 
+        /* Fix up the elastic after a WayNode event - e.g. triggered by undo */
+        private function fixElastic(event:Event):void {
+            var node:Node
+            if (editEnd) {
+              node = selectedWay.getNode(selectedWay.length-1);
+            } else {
+              node = selectedWay.getNode(0);
+            }
+            if (node) { //maybe selectedWay doesn't have any nodes left
+              elastic.start = new Point(node.lon, node.latp);
+            }
+        }
+
                override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
                        switch (event.keyCode) {
                                case 13:                                        return stopDrawing();