Abort the drag when pressing ESC (resolves #73)

This commit is contained in:
Manuel Vögele
2021-08-02 15:51:12 +02:00
parent f1a153a2eb
commit 63b13cbb34
2 changed files with 25 additions and 11 deletions
+14 -10
View File
@@ -110,19 +110,23 @@ export class DragRulerRuler extends Ruler {
game.user.broadcastActivity({ruler: this});
}
else {
const token = this.draggedEntity;
this._endMeasurement();
// Deactivate the drag workflow in mouse
token.mouseInteractionManager._deactivateDragEvents();
token.mouseInteractionManager.state = token.mouseInteractionManager.states.HOVER;
// This will cancel the current drag operation
// Pass in a fake event that hopefully is enough to allow other modules to function
token._onDragLeftCancel(event);
this.dragRulerAbortDrag(event);
}
}
dragRulerAbortDrag(event={preventDefault: () => {return}}) {
const token = this.draggedEntity;
this._endMeasurement();
// Deactivate the drag workflow in mouse
token.mouseInteractionManager._deactivateDragEvents();
token.mouseInteractionManager.state = token.mouseInteractionManager.states.HOVER;
// This will cancel the current drag operation
// Pass in a fake event that hopefully is enough to allow other modules to function
token._onDragLeftCancel(event);
}
async dragRulerRecalculate(tokenIds) {
if (this._state !== Ruler.STATES.MEASURING)
return;