add onblur handler to tool fields to regenerate more intuitively

This commit is contained in:
Stewart Allen 2021-01-04 20:47:55 -05:00
commit c8d974718f
2 changed files with 20 additions and 3 deletions

View file

@ -1979,8 +1979,6 @@
} }
SPACE.onEnterKey([ SPACE.onEnterKey([
// UI.layerSpan, function() { API.show.slices() },
// UI.layerID, function() { API.show.layer(UI.layerID.value) },
UI.scaleX, selectionScale, UI.scaleX, selectionScale,
UI.scaleY, selectionScale, UI.scaleY, selectionScale,
UI.scaleZ, selectionScale, UI.scaleZ, selectionScale,
@ -1999,6 +1997,16 @@
$('rot_z'), selectionRotate $('rot_z'), selectionRotate
]); ]);
UC.onBlur([
UI.toolName,
UI.toolNum,
UI.toolFluteDiam,
UI.toolFluteLen,
UI.toolShaftDiam,
UI.toolShaftLen,
UI.toolTaperTip,
], updateTool);
UI.toolMetric.onclick = updateTool; UI.toolMetric.onclick = updateTool;
UI.toolType.onchange = updateTool; UI.toolType.onchange = updateTool;
// default show gcode pre // default show gcode pre

View file

@ -73,9 +73,18 @@
setUnits, setUnits,
confirm, confirm,
prompt, prompt,
alert alert,
onBlur
}; };
function onBlur(obj, fn) {
if (Array.isArray(obj)) {
for (let o of obj) onBlur(o, fn);
return;
}
obj.addEventListener('blur', fn);
}
function alert(message) { function alert(message) {
return confirm(message, {ok:true}); return confirm(message, {ok:true});
} }