From b99f165a92bd4099795f1a94664d9029176c4f47 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 10 Apr 2020 13:12:13 -0400 Subject: [PATCH] fix text area editing --- js/kiri.js | 12 ++++++++++++ js/moto-ui.js | 29 ++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/js/kiri.js b/js/kiri.js index 7919a59d..60656509 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -1329,6 +1329,8 @@ self.kiri.copyright = exports.COPYRIGHT; nval = parseInt(nval); } } + } else if (uie.type === 'textarea') { + nval = uie.value.trim().split('\n'); } else { continue; } @@ -1366,6 +1368,16 @@ self.kiri.copyright = exports.COPYRIGHT; device.internal++; updateExtruderFields(device); }; + UI.extDel.disabled = device.extruders.length < 2; + UI.extDel.onclick = function() { + device.extruders.splice(device.internal,1); + updateExtruderFields(device); + }; + UI.extAdd.onclick = function() { + device.extruders.push(clone(device.extruders[device.internal])); + device.internal = device.extruders.length - 1; + updateExtruderFields(device); + }; } } diff --git a/js/moto-ui.js b/js/moto-ui.js index 9228f1b6..5e0fddf2 100644 --- a/js/moto-ui.js +++ b/js/moto-ui.js @@ -328,25 +328,28 @@ var gs_moto_ui = exports; btn.appendChild(DOC.createTextNode("edit")); btn.onclick = function(ev) { - btn.parentNode.appendChild(box); - btn.parentNode.onclick = btn.onclick; ev.stopPropagation(); - txt.scrollTop = 0; - txt.scrollLeft = 0; - txt.selectionEnd = 0; - let rows = txt.value.split('\n'); - let cols = 0; - rows.forEach(row => { - cols = Math.max(cols, row.length); - }); - txt.setAttribute("cols", Math.max(30, cols + 1)); - txt.setAttribute("rows", Math.max(10, rows.length + 1)); - // drop clicks on TextArea if (ev.target === txt) { + // drop clicks on TextArea ev.target.focus(); } else { + // first time, button click / show + btn.parentNode.appendChild(box); + btn.parentNode.onclick = btn.onclick; + txt.scrollTop = 0; + txt.scrollLeft = 0; + txt.selectionEnd = 0; + let rows = txt.value.split('\n'); + let cols = 0; + rows.forEach(row => { + cols = Math.max(cols, row.length); + }); + txt.setAttribute("cols", Math.max(30, cols + 1)); + txt.setAttribute("rows", Math.max(10, rows.length + 1)); + let showing = pop === lastPop; hidePop(); + inputAction(); if (!showing) { pop.style.display = "flex"; lastPop = pop;