chiark / gitweb /
js: cancel special selection which clicking on background, etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Apr 2021 00:39:52 +0000 (01:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Apr 2021 00:39:52 +0000 (01:39 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts

index 2dfc468cc908f58bcab53584cb4a819f95e949c2..f1f8e0d0d682c987679565810090bd48a42ac0af 100644 (file)
@@ -1276,6 +1276,13 @@ function rectsel_mouseup(e: MouseEvent) {
   rectsel_path.firstElementChild!.setAttributeNS(null,'d','');
   let pos2 = rectsel_nontrivial_pos2(e);
 
+  if (pos2 == null) {
+    // clicked not on a piece, and didn't drag
+    special_count = null;
+    special_count_reupdate();
+    // we'll bail in a moment, after possibly unselecting things
+  }
+
   let note_already = Object.create(null);
   let c = null;
 
@@ -1317,6 +1324,10 @@ function rectsel_mouseup(e: MouseEvent) {
     return;
   }
 
+  // did the special
+  special_count = null;
+  special_count_reupdate();
+
   if (rectsel_shifted && c.held == us) {
     ungrab_clicked(c.clicked);
     return;