fix tab selection issue, and remove annoying flash of drag-and-drop panel when going...
[potlatch2.git] / net / systemeD / potlatch2 / EditController.as
index ea819b6..099697c 100644 (file)
@@ -3,6 +3,7 @@ package net.systemeD.potlatch2 {
     import net.systemeD.halcyon.MapController;
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.potlatch2.controller.*;
+       import mx.managers.CursorManager;
        import flash.events.*;
        import flash.geom.*;
 
@@ -15,7 +16,16 @@ package net.systemeD.potlatch2 {
         public var state:ControllerState;
         private var _connection:Connection;
         
+               private var keys:Object={};
+               public var clipboards:Object={};
+               public var imagery:Array=[];
 
+               [Embed(source="../../../embedded/pen.png")]             public var pen:Class;
+               [Embed(source="../../../embedded/pen_x.png")]           public var pen_x:Class;
+               [Embed(source="../../../embedded/pen_o.png")]           public var pen_o:Class;
+               [Embed(source="../../../embedded/pen_so.png")]          public var pen_so:Class;
+               [Embed(source="../../../embedded/pen_plus.png")]        public var pen_plus:Class;
+               
         public function EditController(map:Map, tagViewer:TagViewer, toolbox:Toolbox) {
             this._map = map;
             this.tagViewer = tagViewer;
@@ -27,6 +37,7 @@ package net.systemeD.potlatch2 {
             map.parent.addEventListener(MouseEvent.MOUSE_UP, mapMouseEvent);
             map.parent.addEventListener(MouseEvent.MOUSE_DOWN, mapMouseEvent);
             map.parent.addEventListener(MouseEvent.CLICK, mapMouseEvent);
+            map.parent.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
             map.parent.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
         }
 
@@ -48,12 +59,21 @@ package net.systemeD.potlatch2 {
                        toolbox.setEntity(entity);
         }
         
+        private function keyDownHandler(event:KeyboardEvent):void {
+                       keys[event.keyCode]=true;
+               }
+
         private function keyUpHandler(event:KeyboardEvent):void {
             trace("key code "+event.keyCode);
+                       if (keys[event.keyCode]) { delete keys[event.keyCode]; }
             var newState:ControllerState = state.processKeyboardEvent(event);
             setState(newState);            
                }
 
+               public function keyDown(key:Number):Boolean {
+                       return Boolean(keys[key]);
+               }
+
         private function mapMouseEvent(event:MouseEvent):void {
             map.stage.focus = map.parent;
             
@@ -83,13 +103,18 @@ package net.systemeD.potlatch2 {
                 return;
                 
             if ( state != null )
-                state.exitState();
+                state.exitState(newState);
             newState.setController(this);
             newState.setPreviousState(state);
             state = newState;
             state.enterState();
         }
 
+               public function setCursor(cursor:Class):void {
+                       CursorManager.removeAllCursors();
+                       if (cursor) { CursorManager.setCursor(cursor,2,-4,0); }
+               }
+
     }