From 22ba2c42e48bc0a985bd9af218b7e5470463a6a4 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 22 Dec 2017 15:11:02 +0000 Subject: [PATCH] [client] When lifting ctrl, revert to previous tool instead of the brush --- Nibriboard/ClientFiles/Interface.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Nibriboard/ClientFiles/Interface.js b/Nibriboard/ClientFiles/Interface.js index c146c10..bf4f3ad 100644 --- a/Nibriboard/ClientFiles/Interface.js +++ b/Nibriboard/ClientFiles/Interface.js @@ -31,7 +31,7 @@ class Interface extends EventEmitter setupToolSelectors() { this.currentToolElement = this.sidebar.querySelector(".tools .tool-selector[data-selected]"); - this.currentTool = "brush"; + this.lastTool = this.currentTool = "brush"; var toolSelectors = this.sidebar.querySelectorAll(".tools .tool-selector"); for(let i = 0; i < toolSelectors.length; i++) @@ -49,7 +49,7 @@ class Interface extends EventEmitter this.setTool("pan"); }).bind(this)); this.boardWindow.keyboard.on(`keyup-ctrl`, (function(event) { - this.setTool("brush"); + this.revertTool(); }).bind(this)); this.emit("toolchange", { @@ -95,18 +95,27 @@ class Interface extends EventEmitter }); } + /** + * Reverts the currently selected tool back to the last one selected. + */ + revertTool() + { + this.setTool(this.lastTool); + } + /** * Handles tool changes requested by the user. */ handleSelectTool(event) { - let oldTool = this.currentToolElement.dataset.toolName; + this.lastTool = this.currentTool; + delete this.currentToolElement.dataset.selected; this.currentToolElement = event.currentTarget; this.currentToolElement.dataset.selected = "yes"; this.currentTool = this.currentToolElement.dataset.toolName; console.info("Selected tool", this.currentTool); - this.emit("toolchange", { oldTool, newTool: this.currentTool }); + this.emit("toolchange", { oldTool: this.lastTool, newTool: this.currentTool }); } /**