From 73fd86ecd92cd62213f143ad819cb34dfad030d2 Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Thu, 9 Sep 2010 17:38:33 +0000 Subject: [PATCH] Fixed Issue 651: Allow selection of last created element while still in creation mode git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1704 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/extensions/ext-connector.js | 4 ++++ editor/svg-editor.js | 15 +++++++++++---- editor/svgcanvas.js | 5 +++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/editor/extensions/ext-connector.js b/editor/extensions/ext-connector.js index 80a23065..1b74f4bc 100644 --- a/editor/extensions/ext-connector.js +++ b/editor/extensions/ext-connector.js @@ -488,6 +488,10 @@ svgEditor.addExtension("Connector", function(S) { }, selectedChanged: function(opts) { + if(svgCanvas.getMode() == 'connector') { + svgCanvas.setMode('select'); + } + // Use this to update the current selected elements selElems = opts.elems; diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 38463542..f968b08f 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -501,9 +501,12 @@ }()); var setSelectMode = function() { - $('.tool_button_current').removeClass('tool_button_current').addClass('tool_button'); - $('#tool_select').addClass('tool_button_current').removeClass('tool_button'); - $('#styleoverrides').text('#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}'); + var curr = $('.tool_button_current'); + if(curr[0].id !== 'tool_select') { + curr.removeClass('tool_button_current').addClass('tool_button'); + $('#tool_select').addClass('tool_button_current').removeClass('tool_button'); + $('#styleoverrides').text('#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}'); + } svgCanvas.setMode('select'); }; @@ -624,7 +627,6 @@ // select mode and this event fires - we need our UI to be in sync if (mode != "multiselect" && !is_node) { - setSelectMode(); updateToolbar(); } @@ -642,6 +644,11 @@ // called when any element has changed var elementChanged = function(window,elems) { + + if(svgCanvas.getMode() == "select" && $('.tool_button_current')) { + setSelectMode(); + } + for (var i = 0; i < elems.length; ++i) { var elem = elems[i]; diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index f50c1ebf..44526e56 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -5251,6 +5251,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { t.id != "svgcanvas" && t.id != "svgroot") { // switch into "select" mode if we've clicked on an element + clearSelection(true); addToSelection([t], true); canvas.setMode("select"); } @@ -5283,10 +5284,14 @@ var getMouseTarget = this.getMouseTarget = function(evt) { } else if (current_mode == "text" || current_mode == "image" || current_mode == "foreignObject") { // keep us in the tool we were in unless it was a text or image element addToSelection([element], true); + } else { + clearSelection(true); + addToSelection([element], true); } // we create the insert command that is stored on the stack // undo means to call cmd.unapply(), redo means to call cmd.apply() addCommandToHistory(new InsertElementCommand(element)); + call("changed",[element]); }, ani_dur * 1000); }