Prevent Esc from undoing (more than canceling)

main
Isaiah Odhner 2019-12-07 12:54:52 -05:00
parent 631ab0c922
commit 3704293942
2 changed files with 3 additions and 3 deletions

View File

@ -539,8 +539,8 @@ function canvas_pointer_move(e){
// compare buttons other than middle mouse button by using bitwise OR to make that bit of the number the same // compare buttons other than middle mouse button by using bitwise OR to make that bit of the number the same
const MMB = 4; const MMB = 4;
if(e.pointerType != pointer_type || (e.buttons | MMB) != (pointer_buttons | MMB)){ if(e.pointerType != pointer_type || (e.buttons | MMB) != (pointer_buttons | MMB)){
pointer_active = false;
cancel(); cancel();
pointer_active = false; // NOTE: pointer_active used in cancel()
return; return;
} }
} }
@ -614,8 +614,8 @@ $canvas.on("pointerdown", e => {
// Quick Undo when there are multiple pointers (i.e. for touch) // Quick Undo when there are multiple pointers (i.e. for touch)
// see pointermove for other pointer types // see pointermove for other pointer types
if(pointer_active && (reverse ? (button === 2) : (button === 0))){ if(pointer_active && (reverse ? (button === 2) : (button === 0))){
pointer_active = false;
cancel(); cancel();
pointer_active = false; // NOTE: pointer_active used in cancel()
return; return;
} }

View File

@ -968,7 +968,7 @@ function shouldMakeUndoableOnPointerDown(tools) {
return tools.some((tool)=> tool.undoableOnPointerDown); return tools.some((tool)=> tool.undoableOnPointerDown);
} }
function cancel(){ function cancel(){
if(shouldMakeUndoableOnPointerDown(selected_tools)){ undo(); } if(shouldMakeUndoableOnPointerDown(selected_tools) && pointer_active){ undo(); }
$G.triggerHandler("pointerup", "cancel"); $G.triggerHandler("pointerup", "cancel");
for (const selected_tool of selected_tools) { for (const selected_tool of selected_tools) {
selected_tool.cancel && selected_tool.cancel(); selected_tool.cancel && selected_tool.cancel();