From 4b78e8fee148c07182dc0eb58b461c7ca98e98a5 Mon Sep 17 00:00:00 2001 From: unsettledgames <47360416+unsettledgames@users.noreply.github.com> Date: Sat, 4 Apr 2020 15:56:44 +0200 Subject: [PATCH] Fixed undo bug for the rect selection --- js/_mouseEvents.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/_mouseEvents.js b/js/_mouseEvents.js index c5d3cc3..262d78c 100644 --- a/js/_mouseEvents.js +++ b/js/_mouseEvents.js @@ -6,6 +6,7 @@ var lastMousePos; window.addEventListener("mousedown", function (mouseEvent) { // Saving the event in case something else needs it currentMouseEvent = mouseEvent; + canDraw = true; //if no document has been created yet, or this is a dialog open if (!documentCreated || dialogueOpen) return; @@ -27,14 +28,16 @@ window.addEventListener("mousedown", function (mouseEvent) { else if (currentTool == 'moveselection') { if (!cursorInSelectedArea()) { changeTool('pencil'); - undo(); + canDraw = false; } } //saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); updateCursor(); - draw(mouseEvent); + if (canDraw) { + draw(mouseEvent); + } } else if (currentTool == 'pencil' && mouseEvent.which == 3) { currentTool = 'resize-brush';