From e07bce073ba01a8ca724e70dc2cccf79a9480721 Mon Sep 17 00:00:00 2001 From: Ivan Borshchov Date: Fri, 6 May 2022 10:21:42 +0300 Subject: [PATCH] fix for multiple shows one after another --- build/index.html | 10 ++++++---- js/main.js | 2 +- js/selecter.js | 10 ++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build/index.html b/build/index.html index bb63c1f..eee0c2f 100644 --- a/build/index.html +++ b/build/index.html @@ -51,8 +51,9 @@ hoverControl: '#6F6762', hoverControlContent: '#fff', }, - // defaultTool : 'brush', - /* hiddenTools: [ + //defaultTool : 'brush', + //how_to_paste_actions: ['extend_right'], + /*hiddenTools: [ 'select', 'crop', 'pixelize', @@ -75,8 +76,9 @@ 'bucket', 'clear', 'settings', - ], */ - saveHandler: this._onPainterroSave, + ], + */ + saveHandler: this._onPainterroSave, }); window.p.show() const ctx = window.p.ctx; diff --git a/js/main.js b/js/main.js index b98145a..f603c9f 100644 --- a/js/main.js +++ b/js/main.js @@ -855,7 +855,7 @@ class PainterroProc { } handleToolEvent(eventHandler, event) { - if (this.select.imagePlaced) { + if (this.select.imagePlaced || this.select.area.activated) { return this.select[eventHandler](event); } if (this.activeTool && this.activeTool.eventListner) { diff --git a/js/selecter.js b/js/selecter.js index 7012af3..bebb3c6 100644 --- a/js/selecter.js +++ b/js/selecter.js @@ -163,6 +163,12 @@ ${Math.round(pxData[i][j][3] / s)})`; } placeAt(l, t, r, b, img) { + + if (this.imagePlaced) { + // for case when user inserts multiple images one after another without finishing placing them + this.finishPlacing(); + } + this.main.closeActiveTool(true); this.main.setActiveTool(this.main.defaultTool); const scale = this.getScale(); @@ -202,6 +208,7 @@ ${Math.round(pxData[i][j][3] / s)})`; this.area.topl[1], this.area.bottoml[0] - this.area.topl[0], this.area.bottoml[1] - this.area.topl[1]); + this.area.activated = false; } cancelPlacing() { @@ -212,9 +219,12 @@ ${Math.round(pxData[i][j][3] / s)})`; } handleKeyDown(evt) { + console.log(1) if (this.main.inserter.handleKeyDown(evt)) { return true; } + console.log(2) + if (this.shown && this.imagePlaced) { if (evt.keyCode === KEYS.enter) { this.finishPlacing();