From: Ian Jackson Date: Fri, 2 Oct 2020 22:21:25 +0000 (+0100) Subject: mouse stuff X-Git-Tag: otter-0.2.0~800 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=190600335c28238e83c04b8315ee1e649f9e5694;p=otter.git mouse stuff Signed-off-by: Ian Jackson --- diff --git a/templates/script.ts b/templates/script.ts index 905b9efa..f0c929f4 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -350,22 +350,14 @@ function some_mousedown(e : MouseEvent) { if (e.button != 0) { return } if (e.altKey) { return } if (e.metaKey) { return } - if (e.shiftKey) { - if (e.ctrlKey) { - return; - } else { - // group select - } + if (e.ctrlKey) { + return; } else { - if (e.ctrlKey) { - // region indication - } else { - drag_mousedown(e); - } + drag_mousedown(e, e.shiftKey); } } -function drag_mousedown(e : MouseEvent) { +function drag_mousedown(e : MouseEvent, shifted: boolean) { var target = e.target as SVGGraphicsElement; // we check this just now! var piece = target.dataset.piece!; if (!piece) { return; } @@ -376,6 +368,15 @@ function drag_mousedown(e : MouseEvent) { drag_pieces = []; if (held == null) { + if (!shifted) { + for (let tpiece of Object.keys(pieces)) { + let tp = pieces[tpiece]!; + if (tp.held == us) { + set_ungrab(tpiece,tp); + api_piece(api, 'ungrab', tpiece,tp, { }); + } + } + } dragging = DRAGGING.MAYBE_GRAB; drag_add_piece(piece,p); set_grab(piece,p, us);