Shift-R: paste relations from previously selected object, as per #3596.
[potlatch2.git] / net / systemeD / potlatch2 / controller / SelectedPOINode.as
index 2e6af17..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;
         }
  
@@ -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;
@@ -66,6 +74,7 @@ package net.systemeD.potlatch2.controller {
             if(firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
+            copyRelations(firstSelected);
                        layer.setPurgable(selection,true);
             clearSelection(newState);
         }