select and move POI nodes, and a handful of smaller fixes too
[potlatch2.git] / net / systemeD / potlatch2 / controller / NoSelection.as
index cdfcc1a916054aaaa79751ee1a203fa41ddf973d..c82c24475f9f09787fb976f97b9afb344309f4a7 100644 (file)
@@ -13,20 +13,26 @@ package net.systemeD.potlatch2.controller {
                override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
                        var focus:Entity = getTopLevelFocusEntity(entity);
 
-                       if ( event.type == MouseEvent.CLICK ) {
-                               if ( focus is Way ) {
+                       if ( event.type == MouseEvent.MOUSE_DOWN ) {
+                               if ( entity is Way ) {
                                        return new SelectedWay(focus as Way);
-                               } else if ( focus is Node ) {
-                                       // *** select node
-                                       Globals.vars.root.addDebug("- selected POI");
+                } else if ( focus is Node ) {
+                                       return new DragPOINode(entity as Node,event,false);
+                } else if ( entity is Node && focus is Way ) {
+                                       return new DragWayNode(focus as Way,entity as Node,event,false);
                                }
                        } else if (event.type==MouseEvent.MOUSE_UP && focus==null && map.dragstate!=map.DRAGGING) {
                                map.dragstate=map.NOT_DRAGGING;
-                               return new CreateWay(event);
+                               var startNode:Node = controller.connection.createNode(
+                                       {}, 
+                                       controller.map.coord2lat(event.localY),
+                                       controller.map.coord2lon(event.localX));
+                               var way:Way = controller.connection.createWay({}, [startNode]);
+                               return new DrawWay(way, true, false);
                        } else if ( event.type == MouseEvent.MOUSE_OVER ) {
-                               controller.map.setHighlight(focus, "hover", true);
+                               controller.map.setHighlight(focus, { hover: true });
                        } else if ( event.type == MouseEvent.MOUSE_OUT ) {
-                               controller.map.setHighlight(focus, "hover", false);
+                               controller.map.setHighlight(focus, { hover: false });
                        } else if ( event.type == MouseEvent.MOUSE_DOWN ) {
                        }
                        return this;
@@ -45,6 +51,12 @@ package net.systemeD.potlatch2.controller {
                        }
                }
 
+        override public function enterState():void {
+                       Globals.vars.root.addDebug("**** -> "+this);
+        }
+        override public function exitState():void {
+                       Globals.vars.root.addDebug("**** <- "+this);
+        }
                override public function toString():String {
                        return "NoSelection";
                }