Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

Commit 45de849

Browse files
committed
Fix #1138, dragging in the background when there's already a selection will now create a new selection
1 parent 62e68ed commit 45de849

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

addon/data/shooter-interactive-worker.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ mousedownPos (object with x/y during draggingReady, shows where the selection st
3636
selectedPos (object with x/y/h/w during selected or dragging, gives the entire selection)
3737
resizeDirection (string: top, topLeft, etc, during resizing)
3838
resizeStartPos (x/y position where resizing started)
39+
mouseupNoAutoselect (true if a mouseup in draggingReady should not trigger autoselect)
3940
4041
*/
4142

@@ -147,6 +148,7 @@ let resizeDirection;
147148
let resizeStartPos;
148149
let resizeStartSelected;
149150
let resizeHasMoved;
151+
let mouseupNoAutoselect = false;
150152

151153
/** Represents a selection box: */
152154
class Selection {
@@ -384,6 +386,7 @@ stateHandlers.draggingReady = {
384386

385387
start: function () {
386388
ui.Box.remove();
389+
ui.WholePageOverlay.display(standardOverlayCallbacks);
387390
},
388391

389392
mousemove: function (event) {
@@ -400,6 +403,11 @@ stateHandlers.draggingReady = {
400403

401404
mouseup: function (event) {
402405
// If we don't get into "dragging" then we attempt an autoselect
406+
if (mouseupNoAutoselect) {
407+
sendEvent("cancel-selection", "selection-background-mousedown");
408+
setState("crosshairs");
409+
return false;
410+
}
403411
let el = this.findGoodEl();
404412
if (el) {
405413
let rect = el.getBoundingClientRect();
@@ -515,6 +523,10 @@ stateHandlers.draggingReady = {
515523
el = el.parentNode;
516524
}
517525
return null;
526+
},
527+
528+
end: function () {
529+
mouseupNoAutoselect = false;
518530
}
519531

520532
};
@@ -566,18 +578,16 @@ stateHandlers.selected = {
566578
if (direction) {
567579
sendEvent("start-resize-selection", "handle");
568580
stateHandlers.resizing.startResize(event, direction);
569-
event.preventDefault();
570-
return false;
571-
}
572-
if (! ui.Box.isSelection(target)) {
573-
sendEvent("cancel-selection", "selection-background-mousedown");
574-
setState("crosshairs");
575-
} else {
581+
} else if (ui.Box.isSelection(target)) {
576582
sendEvent("start-move-selection", "selection");
577583
stateHandlers.resizing.startResize(event, "move");
578-
event.preventDefault();
579-
return false;
584+
} else {
585+
mousedownPos = new Pos(event.pageX, event.pageY);
586+
mouseupNoAutoselect = true;
587+
setState("draggingReady");
580588
}
589+
event.preventDefault();
590+
return false;
581591
}
582592
};
583593

0 commit comments

Comments
 (0)