From 9b6866991bf8a7124f09096bac4bbd3080784d86 Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Sat, 9 Oct 2021 14:53:35 -0500 Subject: [PATCH] deselect when drawing path --- src/css/panel.css | 4 +++ src/js/Text.js | 3 +- src/js/svgcanvas.js | 75 +++++++++++++++++++++++++-------------------- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/css/panel.css b/src/css/panel.css index 636d3d7..4d8db68 100644 --- a/src/css/panel.css +++ b/src/css/panel.css @@ -38,3 +38,7 @@ #panels.multiselected #multiselected_panel .hidable { display: none; } + +#tool_place_text_on_path { + display: none; +} \ No newline at end of file diff --git a/src/js/Text.js b/src/js/Text.js index 7188a63..46f8ece 100644 --- a/src/js/Text.js +++ b/src/js/Text.js @@ -101,8 +101,9 @@ MD.Text = function(){ .keyup(function(e){ e.stopPropagation(); if (e.key === "Escape" || e.key === "Enter") { - if (!$("#text_panel").hasClass("text-path")) svgCanvas.textActions.toSelectMode(); + svgCanvas.textActions.toSelectMode(); this.blur(); + editor.saveCanvas(); return editor.escapeMode(); } svgCanvas.setTextContent(this.value); diff --git a/src/js/svgcanvas.js b/src/js/svgcanvas.js index 827a922..7391f42 100644 --- a/src/js/svgcanvas.js +++ b/src/js/svgcanvas.js @@ -3480,13 +3480,15 @@ var textActions = canvas.textActions = function() { }); cursor = getElem("selectorParentGroup").appendChild(cursor); } - + if(!blinker) { blinker = setInterval(function() { var show = (cursor.getAttribute('display') === 'none'); - cursor.setAttribute('display', show?'inline':'none'); + cursor.setAttribute('display', show ? 'inline': 'none'); }, 600); } + + console.log("blinker", blinker) var start_pt = ptToScreen(charbb.x, textbb.y); var end_pt = ptToScreen(charbb.x, (textbb.y + textbb.height)); @@ -3820,42 +3822,42 @@ var pathActions = canvas.pathActions = function() { p.setAttribute("d", pathActions.convertPath(p)); } - // TODO: Move into path.js - svgedit.path.Path.prototype.endChanges = function(text) { - if(svgedit.browser.isWebkit()) resetD(this.elem); - var cmd = new ChangeElementCommand(this.elem, {d: this.last_d}, text); - addCommandToHistory(cmd); - call("changed", [this.elem]); - } +// TODO: Move into path.js + svgedit.path.Path.prototype.endChanges = function(text) { + if(svgedit.browser.isWebkit()) resetD(this.elem); + var cmd = new ChangeElementCommand(this.elem, {d: this.last_d}, text); + addCommandToHistory(cmd); + call("changed", [this.elem]); + } - svgedit.path.Path.prototype.addPtsToSelection = function(indexes) { - if(!$.isArray(indexes)) indexes = [indexes]; - for(var i=0; i< indexes.length; i++) { - var index = indexes[i]; - var seg = this.segs[index]; - if(seg.ptgrip) { - if(this.selected_pts.indexOf(index) == -1 && index >= 0) { - this.selected_pts.push(index); - } + svgedit.path.Path.prototype.addPtsToSelection = function(indexes) { + if(!$.isArray(indexes)) indexes = [indexes]; + for(var i=0; i< indexes.length; i++) { + var index = indexes[i]; + var seg = this.segs[index]; + if(seg.ptgrip) { + if(this.selected_pts.indexOf(index) == -1 && index >= 0) { + this.selected_pts.push(index); } - }; - this.selected_pts.sort(); - var i = this.selected_pts.length, - grips = new Array(i); - // Loop through points to be selected and highlight each - while(i--) { - var pt = this.selected_pts[i]; - var seg = this.segs[pt]; - seg.select(true); - grips[i] = seg.ptgrip; } - // TODO: Correct this: - pathActions.canDeleteNodes = true; - - pathActions.closed_subpath = this.subpathIsClosed(this.selected_pts[0]); - - call("selected", grips); + }; + this.selected_pts.sort(); + var i = this.selected_pts.length, + grips = new Array(i); + // Loop through points to be selected and highlight each + while(i--) { + var pt = this.selected_pts[i]; + var seg = this.segs[pt]; + seg.select(true); + grips[i] = seg.ptgrip; } + // TODO: Correct this: + pathActions.canDeleteNodes = true; + + pathActions.closed_subpath = this.subpathIsClosed(this.selected_pts[0]); + + call("selected", grips); + } var current_path = null, drawn_path = null, @@ -3936,6 +3938,11 @@ var pathActions = canvas.pathActions = function() { return { mouseDown: function(evt, mouse_target, start_x, start_y) { if(current_mode === "path") { + + // deselect when start draw + + svgCanvas.removeFromSelection(svgCanvas.getSelectedElems()) + mouse_x = start_x; mouse_y = start_y;