mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
fix: Quick box selection causes units to be immediately deselected
This commit is contained in:
@@ -948,29 +948,25 @@ export class Map extends L.Map {
|
|||||||
|
|
||||||
#onDragStart(e: any) {
|
#onDragStart(e: any) {
|
||||||
this.#isDragging = true;
|
this.#isDragging = true;
|
||||||
|
|
||||||
|
this.#mouseHandler.stopEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onDragEnd(e: any) {
|
#onDragEnd(e: any) {
|
||||||
/* Delay the drag end event so that any other event in the queue still sees the map in dragging mode */
|
this.#isDragging = false;
|
||||||
window.setTimeout(() => {
|
|
||||||
this.#isDragging = false;
|
|
||||||
}, SHORT_PRESS_MILLISECONDS + 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#onSelectionStart(e: any) {
|
#onSelectionStart(e: any) {
|
||||||
this.#isSelecting = true;
|
this.#isSelecting = true;
|
||||||
|
|
||||||
|
this.#mouseHandler.stopEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onSelectionEnd(e: any) {
|
#onSelectionEnd(e: any) {
|
||||||
getApp().getUnitsManager().selectFromBounds(e.selectionBounds);
|
getApp().getUnitsManager().selectFromBounds(e.selectionBounds);
|
||||||
|
|
||||||
// Autodisable the selection mode if touchscreen
|
this.setSelectionEnabled(false);
|
||||||
if ("ontouchstart" in window) this.setSelectionEnabled(false);
|
this.#isSelecting = false;
|
||||||
|
|
||||||
/* Delay the event so that any other event in the queue still sees the map in selection mode */
|
|
||||||
window.setTimeout(() => {
|
|
||||||
this.#isSelecting = false;
|
|
||||||
}, SHORT_PRESS_MILLISECONDS + 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#onLeftMouseReleased(e: any) {
|
#onLeftMouseReleased(e: any) {
|
||||||
@@ -981,12 +977,6 @@ export class Map extends L.Map {
|
|||||||
}
|
}
|
||||||
this.#isRotatingDestination = false;
|
this.#isRotatingDestination = false;
|
||||||
this.setKeepRelativePositions(false);
|
this.setKeepRelativePositions(false);
|
||||||
|
|
||||||
/* Delay the event so that any other event in the queue still sees the map in selection mode */
|
|
||||||
window.setTimeout(() => {
|
|
||||||
this.setSelectionEnabled(false);
|
|
||||||
this.#isSelecting = false;
|
|
||||||
}, SHORT_PRESS_MILLISECONDS + 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#onMouseWheelReleased(e: any) {
|
#onMouseWheelReleased(e: any) {
|
||||||
@@ -1280,6 +1270,8 @@ export class Map extends L.Map {
|
|||||||
this.#previousZoom = this.getZoom();
|
this.#previousZoom = this.getZoom();
|
||||||
if (this.#centeredUnit != null) this.#panToUnit(this.#centeredUnit);
|
if (this.#centeredUnit != null) this.#panToUnit(this.#centeredUnit);
|
||||||
this.#isZooming = true;
|
this.#isZooming = true;
|
||||||
|
|
||||||
|
this.#mouseHandler.stopEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onZoom(e: any) {
|
#onZoom(e: any) {
|
||||||
|
|||||||
@@ -69,6 +69,23 @@ export class MapMouseHandler {
|
|||||||
this.#state = state;
|
this.#state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopEvents() {
|
||||||
|
if (this.#leftMouseDownTimeout) {
|
||||||
|
clearTimeout(this.#leftMouseDownTimeout);
|
||||||
|
this.#leftMouseDownTimeout = null;
|
||||||
|
}
|
||||||
|
if (this.#rightMouseDownTimeout) {
|
||||||
|
clearTimeout(this.#rightMouseDownTimeout);
|
||||||
|
this.#rightMouseDownTimeout = null;
|
||||||
|
}
|
||||||
|
if (this.#debounceTimeout) {
|
||||||
|
clearTimeout(this.#debounceTimeout);
|
||||||
|
this.#debounceTimeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState(MapMouseHandlerState.IDLE);
|
||||||
|
}
|
||||||
|
|
||||||
#onMouseDown = (e: LeafletMouseEvent) => {
|
#onMouseDown = (e: LeafletMouseEvent) => {
|
||||||
if (e.originalEvent.button === 0) {
|
if (e.originalEvent.button === 0) {
|
||||||
this.leftMousePressed(e);
|
this.leftMousePressed(e);
|
||||||
Reference in New Issue
Block a user