deselect when drawing path

master
Mark MacKay 2021-10-09 14:53:35 -05:00
parent 65ad8aa92e
commit 9b6866991b
3 changed files with 47 additions and 35 deletions

View File

@ -38,3 +38,7 @@
#panels.multiselected #multiselected_panel .hidable { #panels.multiselected #multiselected_panel .hidable {
display: none; display: none;
} }
#tool_place_text_on_path {
display: none;
}

View File

@ -101,8 +101,9 @@ MD.Text = function(){
.keyup(function(e){ .keyup(function(e){
e.stopPropagation(); e.stopPropagation();
if (e.key === "Escape" || e.key === "Enter") { if (e.key === "Escape" || e.key === "Enter") {
if (!$("#text_panel").hasClass("text-path")) svgCanvas.textActions.toSelectMode(); svgCanvas.textActions.toSelectMode();
this.blur(); this.blur();
editor.saveCanvas();
return editor.escapeMode(); return editor.escapeMode();
} }
svgCanvas.setTextContent(this.value); svgCanvas.setTextContent(this.value);

View File

@ -3484,10 +3484,12 @@ var textActions = canvas.textActions = function() {
if(!blinker) { if(!blinker) {
blinker = setInterval(function() { blinker = setInterval(function() {
var show = (cursor.getAttribute('display') === 'none'); var show = (cursor.getAttribute('display') === 'none');
cursor.setAttribute('display', show?'inline':'none'); cursor.setAttribute('display', show ? 'inline': 'none');
}, 600); }, 600);
} }
console.log("blinker", blinker)
var start_pt = ptToScreen(charbb.x, textbb.y); var start_pt = ptToScreen(charbb.x, textbb.y);
var end_pt = ptToScreen(charbb.x, (textbb.y + textbb.height)); 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)); p.setAttribute("d", pathActions.convertPath(p));
} }
// TODO: Move into path.js // TODO: Move into path.js
svgedit.path.Path.prototype.endChanges = function(text) { svgedit.path.Path.prototype.endChanges = function(text) {
if(svgedit.browser.isWebkit()) resetD(this.elem); if(svgedit.browser.isWebkit()) resetD(this.elem);
var cmd = new ChangeElementCommand(this.elem, {d: this.last_d}, text); var cmd = new ChangeElementCommand(this.elem, {d: this.last_d}, text);
addCommandToHistory(cmd); addCommandToHistory(cmd);
call("changed", [this.elem]); call("changed", [this.elem]);
} }
svgedit.path.Path.prototype.addPtsToSelection = function(indexes) { svgedit.path.Path.prototype.addPtsToSelection = function(indexes) {
if(!$.isArray(indexes)) indexes = [indexes]; if(!$.isArray(indexes)) indexes = [indexes];
for(var i=0; i< indexes.length; i++) { for(var i=0; i< indexes.length; i++) {
var index = indexes[i]; var index = indexes[i];
var seg = this.segs[index]; var seg = this.segs[index];
if(seg.ptgrip) { if(seg.ptgrip) {
if(this.selected_pts.indexOf(index) == -1 && index >= 0) { if(this.selected_pts.indexOf(index) == -1 && index >= 0) {
this.selected_pts.push(index); 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; this.selected_pts.sort();
var i = this.selected_pts.length,
pathActions.closed_subpath = this.subpathIsClosed(this.selected_pts[0]); grips = new Array(i);
// Loop through points to be selected and highlight each
call("selected", grips); 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, var current_path = null,
drawn_path = null, drawn_path = null,
@ -3936,6 +3938,11 @@ var pathActions = canvas.pathActions = function() {
return { return {
mouseDown: function(evt, mouse_target, start_x, start_y) { mouseDown: function(evt, mouse_target, start_x, start_y) {
if(current_mode === "path") { if(current_mode === "path") {
// deselect when start draw
svgCanvas.removeFromSelection(svgCanvas.getSelectedElems())
mouse_x = start_x; mouse_x = start_x;
mouse_y = start_y; mouse_y = start_y;