- public class NoSelection extends ControllerState {
- public function NoSelection() {
- }
-
- override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
- var focus:Entity = getTopLevelFocusEntity(entity);
- if ( event.type == MouseEvent.CLICK )
- if ( focus is Way )
- return new SelectedWay(focus as Way);
- else if ( focus is Node )
- trace("select poi");
- else if ( focus == null )
- return new CreateWay(event);
- else if ( event.type == MouseEvent.MOUSE_OVER )
- controller.map.setHighlight(focus, "hover", true);
- else if ( event.type == MouseEvent.MOUSE_OUT )
- controller.map.setHighlight(focus, "hover", false);
-
- return this;
+ public class NoSelection extends ControllerState {
+
+ public function NoSelection() {
+ }
+
+ override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
+ var focus:Entity = getTopLevelFocusEntity(entity);
+
+ if (event.type==MouseEvent.MOUSE_UP && focus==null && map.dragstate!=map.DRAGGING) {
+ map.dragstate=map.NOT_DRAGGING;
+ var undo:CompositeUndoableAction = new CompositeUndoableAction("Begin way");
+ var startNode:Node = controller.connection.createNode(
+ {},
+ controller.map.coord2lat(event.localY),
+ controller.map.coord2lon(event.localX), undo.push);
+ var way:Way = controller.connection.createWay({}, [startNode], undo.push);
+ MainUndoStack.getGlobalStack().addAction(undo);
+ return new DrawWay(way, true, false);
+ }
+ var cs:ControllerState = sharedMouseEvents(event, entity);
+ if (cs) return cs;
+ return this;
+ }
+
+ override public function enterState():void {
+ Globals.vars.root.addDebug("**** -> "+this);