Shift-R: paste relations from previously selected object, as per #3596.
[potlatch2.git] / net / systemeD / potlatch2 / controller / SelectedPOINode.as
index 9b893cb..46d0b75 100644 (file)
@@ -1,13 +1,16 @@
 package net.systemeD.potlatch2.controller {
        import flash.events.*;
+       import flash.display.*;
        import flash.ui.Keyboard;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.halcyon.connection.*;
+    import net.systemeD.halcyon.MapPaint;
 
     public class SelectedPOINode extends ControllerState {
         protected var initNode:Node;
 
-        public function SelectedPOINode(node:Node) {
+        public function SelectedPOINode(node:Node, layer:MapPaint=null) {
+                       if (layer) this.layer=layer;
             initNode = node;
         }
  
@@ -16,7 +19,7 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            editableLayer.setHighlight(node, { selected: true });
+            layer.setHighlight(node, { selected: true });
             selection = [node];
             controller.updateSelectionUI();
             initNode = node;
@@ -24,7 +27,7 @@ package net.systemeD.potlatch2.controller {
                 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-                editableLayer.setHighlight(firstSelected, { selected: false });
+                layer.setHighlight(firstSelected, { selected: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -32,11 +35,14 @@ package net.systemeD.potlatch2.controller {
         
         override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
                        if (event.type==MouseEvent.MOUSE_MOVE) { return this; }
-                       if (event.type==MouseEvent.MOUSE_DOWN && event.ctrlKey && entity && entity!=firstSelected) {
-                               return new SelectedMultiple([firstSelected,entity]);
-                       }
-                       if (event.type==MouseEvent.MOUSE_DOWN && event.shiftKey && !entity) {
+                       var paint:MapPaint = getMapPaint(DisplayObject(event.target));
+
+                       if (event.type==MouseEvent.MOUSE_DOWN && event.ctrlKey && !event.altKey && entity && entity!=firstSelected && paint==layer) {
+                               return new SelectedMultiple([firstSelected,entity],layer);
+                       } else if (event.type==MouseEvent.MOUSE_DOWN && event.shiftKey && !entity && !layer.isBackground) {
                                return new DrawQuadrilateral(firstSelected as Node);
+                       } else if ( event.type == MouseEvent.MOUSE_UP && entity==firstSelected ) {
+                               return this;
                        }
                        var cs:ControllerState = sharedMouseEvents(event, entity);
                        return cs ? cs : this;
@@ -46,7 +52,9 @@ package net.systemeD.potlatch2.controller {
                        switch (event.keyCode) {
                                case Keyboard.BACKSPACE:        return deletePOI();
                                case Keyboard.DELETE:           return deletePOI();
-                               case 82:                                        repeatTags(firstSelected); return this; // 'R'
+                case 82:  /* R */           { if (! event.shiftKey) repeatTags(firstSelected); 
+                                              else                  repeatRelations(firstSelected);
+                                              return this; }
                        }
                        var cs:ControllerState = sharedKeyboardEvents(event);
                        return cs ? cs : this;
@@ -60,14 +68,14 @@ package net.systemeD.potlatch2.controller {
 
         override public function enterState():void {
             selectNode(initNode);
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
         override public function exitState(newState:ControllerState):void {
-trace("firstSelected is "+firstSelected);
             if(firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
-                       editableLayer.setPurgable(selection,true);
+            copyRelations(firstSelected);
+                       layer.setPurgable(selection,true);
             clearSelection(newState);
         }