fix text area editing

This commit is contained in:
Stewart Allen 2020-04-10 13:12:13 -04:00
commit b99f165a92
2 changed files with 28 additions and 13 deletions

View file

@ -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);
};
}
}

View file

@ -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;