From ce993ba84ae4d116a62160e3576c7f7b69c72ca6 Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Fri, 25 Sep 2020 18:49:56 +0200
Subject: [PATCH] Fix the Alt-click popup issue.

Fixes a residual regression with MR !528 (Findbox fixes) reported by
Joseph Gastelais, which causes temporary run mode to stick when opening
a subpatch using Alt-click (i.e., mouse click on the subpatch in
temporary run mode). Resolved using Jonathan's fake keyup trick.
---
 pd/nw/pd_canvas.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js
index a0bfb1a2e..70604e12b 100644
--- a/pd/nw/pd_canvas.js
+++ b/pd/nw/pd_canvas.js
@@ -383,6 +383,15 @@ var canvas_events = (function() {
                     (pointer_y + svg_view.y),
                     b, mod
                 );
+                // If Alt is pressed on a box_text, fake a keyup to prevent
+                // dangling temp runmode in case the click opens a subpatch.
+                // XXXFIXME: This will also end temporary runmode if the
+                // object being clicked is *not* a subpatch, so we might want
+                // to check for this -- I just don't know how to do that. -ag
+                if (evt.altKey &&
+                    evt.target.parentNode.classList.contains("box_text")) {
+                    pdgui.canvas_sendkey(name, 0, evt, "Alt", 0);
+                }
                 //evt.stopPropagation();
                 //evt.preventDefault();
             },
-- 
GitLab