1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[client] When lifting ctrl, revert to previous tool instead of the brush

This commit is contained in:
Starbeamrainbowlabs 2017-12-22 15:11:02 +00:00
parent 0897dcdaeb
commit 22ba2c42e4
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -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 });
}
/**