Skip to content

Commit cf84bb0

Browse files
committed
image editor: right-click can drag when not used by a tool
1 parent 5804cc9 commit cf84bb0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/wwwroot/js/genpage/helpers/image_editor.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ class ImageEditor {
520520
});
521521
canvas.addEventListener('drop', (e) => this.handleCanvasImageDrop(e));
522522
canvas.addEventListener('contextmenu', (e) => {
523-
if (this.activeTool && this.activeTool.onContextMenu(e)) {
524-
e.preventDefault();
525-
}
523+
e.preventDefault();
526524
});
527525
this.ctx = canvas.getContext('2d');
528526
canvas.style.cursor = 'none';
@@ -724,16 +722,20 @@ class ImageEditor {
724722
}
725723

726724
onMouseDown(e) {
725+
// 1 = middle, 2 = right
727726
if (this.altDown || e.button == 1) {
728727
this.handleAltDown();
729728
}
729+
if (e.button == 2 && this.activeTool && !this.activeTool.onContextMenu(e)) {
730+
this.handleAltDown();
731+
}
730732
this.mouseDown = true;
731733
this.activeTool.onMouseDown(e);
732734
this.redraw();
733735
}
734736

735737
onMouseUp(e) {
736-
if (e.button == 1) {
738+
if (e.button == 1 || e.button == 2) {
737739
this.handleAltUp();
738740
}
739741
this.mouseDown = false;

0 commit comments

Comments
 (0)