Allow deleting of waypoints with the 'X' key (resolves #14)
This commit is contained in:
+26
@@ -8,6 +8,7 @@ Hooks.once("init", () => {
|
||||
registerSettings()
|
||||
hookTokenDragHandlers()
|
||||
hookRulerFunctions()
|
||||
hookKeyboardManagerFunctions()
|
||||
patchRulerHighlightMeasurement()
|
||||
|
||||
availableSpeedProviders["native"] = nativeSpeedProvider
|
||||
@@ -100,6 +101,31 @@ function hookRulerFunctions() {
|
||||
}
|
||||
}
|
||||
|
||||
function hookKeyboardManagerFunctions() {
|
||||
const originalHandleKeys = KeyboardManager.prototype._handleKeys
|
||||
KeyboardManager.prototype._handleKeys = function (event, key, up) {
|
||||
const eventHandled = handleKeys.call(this, event, key, up)
|
||||
if (!eventHandled)
|
||||
originalHandleKeys.call(this, event, key, up)
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeys(event, key, up) {
|
||||
if (up || event.repeat || this.hasFocus)
|
||||
return false
|
||||
|
||||
if (key.toLowerCase() === "x") return onKeyDownX()
|
||||
return false
|
||||
}
|
||||
|
||||
function onKeyDownX() {
|
||||
if (!canvas.controls.ruler.isDragRuler)
|
||||
return false
|
||||
|
||||
deleteWaypoint()
|
||||
return true
|
||||
}
|
||||
|
||||
function onTokenLeftDragStart(event) {
|
||||
canvas.controls.ruler.draggedToken = this
|
||||
const tokenCenter = {x: this.x + canvas.grid.grid.w / 2, y: this.y + canvas.grid.grid.h / 2}
|
||||
|
||||
Reference in New Issue
Block a user