Tidy and fix the pull-through code
authorRichard Fairhurst <richard@systemeD.net>
Mon, 3 Oct 2011 15:37:40 +0000 (16:37 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Mon, 3 Oct 2011 15:37:40 +0000 (16:37 +0100)
net/systemeD/potlatch2/controller/ControllerState.as

index 05417cd..a905d23 100644 (file)
@@ -108,9 +108,13 @@ package net.systemeD.potlatch2.controller {
                        if ( paint && paint.isBackground ) {
                                if (event.type == MouseEvent.MOUSE_DOWN && ((event.shiftKey && event.ctrlKey) || event.altKey) ) {
                                        // alt-click to pull data out of vector background layer
-                                       var newSelection:Array=[];
-                                       if (selection.indexOf(entity)==-1) { selection=[entity]; }
-                                       for each (var entity:Entity in selection) {
+                                       // first, create a list of the alt-clicked item, plus anything else already selected (assuming it's in the same layer!)
+                                       var itemsToPullThrough:Array=[]
+                                       if (_selection.length && firstSelected.connection==entity.connection) itemsToPullThrough=_selection.slice();
+                                       if (itemsToPullThrough.indexOf(entity)==-1) itemsToPullThrough.push(entity);
+                                       // make sure they're unhighlighted, and pull them through
+                                       var newSelection:Array=[]
+                                       for each (var entity:Entity in itemsToPullThrough) {
                                                paint.setHighlight(entity, { hover:false, selected: false });
                                                if (entity is Way) paint.setHighlightOnNodes(Way(entity), { selectedway: false });
                                                newSelection.push(paint.pullThrough(entity,controller.map.editableLayer));
@@ -317,7 +321,7 @@ package net.systemeD.potlatch2.controller {
 
                        // If there's an existing outer in the selection, use that
                        for each (entity in selection) {
-                               if (!entity is Way) return {};
+                               if (!(entity is Way)) return {};
                                var r:Array=entity.findParentRelationsOfType('multipolygon','outer');
                                if (r.length) { outer=Way(entity); relation=r[0]; }
                        }
@@ -326,7 +330,7 @@ package net.systemeD.potlatch2.controller {
                        var largest:Number=0;
                        if (!outer) {
                                for each (entity in selection) {
-                                       if (!entity is Way) return {};
+                                       if (!(entity is Way)) return {};
                                        if (!Way(entity).isArea()) return {};
                                        var props:Object=layer.wayUIProperties(entity as Way);
                                        if (props.patharea>largest) { outer=Way(entity); largest=props.patharea; }
@@ -337,7 +341,7 @@ package net.systemeD.potlatch2.controller {
                        // Identify the inners
                        for each (entity in selection) {
                                if (entity==outer) continue;
-                               if (!entity is Way) return {};
+                               if (!(entity is Way)) return {};
                                if (!Way(entity).isArea()) return {};
                                var node:Node=Way(entity).getFirstNode();
                                if (outer.pointWithin(node.lon,node.lat)) inners.push(entity);