keyboard shortcut for Undo, plus gratuitous use of ternary operator
[potlatch2.git] / net / systemeD / potlatch2 / controller / NoSelection.as
1 package net.systemeD.potlatch2.controller {
2         import flash.events.*;
3         import flash.display.*;
4         import net.systemeD.potlatch2.EditController;
5         import net.systemeD.halcyon.connection.*;
6         import net.systemeD.halcyon.Map;
7         import net.systemeD.halcyon.MapPaint;
8         import net.systemeD.halcyon.vectorlayers.VectorLayer;
9         import net.systemeD.halcyon.Globals;
10
11         public class NoSelection extends ControllerState {
12
13                 public function NoSelection() {
14                 }
15
16                 override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
17                         var focus:Entity = getTopLevelFocusEntity(entity);
18
19                         if (event.type==MouseEvent.MOUSE_UP && focus==null && map.dragstate!=map.DRAGGING) {
20                                 map.dragstate=map.NOT_DRAGGING;
21                                 var undo:CompositeUndoableAction = new CompositeUndoableAction("Begin way");
22                                 var startNode:Node = controller.connection.createNode(
23                                         {}, 
24                                         controller.map.coord2lat(event.localY),
25                                         controller.map.coord2lon(event.localX), undo.push);
26                                 var way:Way = controller.connection.createWay({}, [startNode], undo.push);
27                                 MainUndoStack.getGlobalStack().addAction(undo);
28                                 return new DrawWay(way, true, false);
29                         }
30                         var cs:ControllerState = sharedMouseEvents(event, entity);
31                         return cs ? cs : this;
32                 }
33                 
34                 override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
35                         var cs:ControllerState = sharedKeyboardEvents(event);
36                         return cs ? cs : this;
37                 }
38                 
39         override public function enterState():void {
40                         Globals.vars.root.addDebug("**** -> "+this);
41         }
42         override public function exitState():void {
43                         Globals.vars.root.addDebug("**** <- "+this);
44         }
45                 override public function toString():String {
46                         return "NoSelection";
47                 }
48
49         }
50 }