From 31ec4fec919482a6bfcdfbd6f6383230af3921db Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 31 Jan 2010 20:17:50 +0000 Subject: [PATCH] Fix Issue 412: Press 'A' to select all elements in the current layer git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1312 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 11 ++++++----- editor/svgcanvas.js | 14 +++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 5005cf79..1003cbad 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1275,12 +1275,12 @@ function svg_edit_setup() { var selectNext = function() { svgCanvas.cycleElement(1); - } + }; var selectPrev = function() { svgCanvas.cycleElement(0); - } - + }; + var rotateSelected = function(cw) { if (selectedElement == null || multiselected) return; var step = 5; @@ -1288,7 +1288,7 @@ function svg_edit_setup() { var new_angle = $('#angle').val()*1 + step; svgCanvas.setRotationAngle(new_angle); updateContextPanel(); - } + }; var clickClear = function(){ $.confirm(uiStrings.QwantToClear, function(ok) { @@ -2330,7 +2330,8 @@ function svg_edit_setup() { {key: ['up', true], fn: function(){moveSelected(0,-1);}}, {key: ['down', true], fn: function(){moveSelected(0,1);}}, {key: ['left', true], fn: function(){moveSelected(-1,0);}}, - {key: ['right', true], fn: function(){moveSelected(1,0);}} + {key: ['right', true], fn: function(){moveSelected(1,0);}}, + {key: 'A', fn: function(){svgCanvas.selectAllInCurrentLayer();}} ]; // Tooltips not directly associated with a single function diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 6210a0b3..8fbe432e 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2217,7 +2217,7 @@ function BatchCommand(text) { while (i--) { var elem = elemsToAdd[i]; // we ignore any selectors - if (!elem || elem.id.substr(0,13) == "selectorGrip_") continue; + if (!elem || elem.id.substr(0,13) == "selectorGrip_" || !this.getBBox(elem)) continue; // if it's not already there, add it if (selectedElements.indexOf(elem) == -1) { selectedElements[j] = elem; @@ -5656,6 +5656,18 @@ function BatchCommand(text) { } } }; + + // Function: selectAllInCurrentLayer + // Clears the selection, then adds all elements in the current layer to the selection. + // This function then fires the selected event. + this.selectAllInCurrentLayer = function() { + if (current_layer) { + canvas.clearSelection(); + canvas.addToSelection($(current_layer).children()); + current_mode = "select"; + call("selected", selectedElements); + } + }; // Function: clear // Clears the current document. This is not an undoable action.