From 8ae594377f7c128aea96907ba39f496792b577f1 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Sun, 9 Oct 2016 14:26:58 -0400
Subject: [PATCH] fix Bring to Front/Send to Back by putting them in the popup
 menu. It would be better if the user could select multiple objects at a time,
 but the x/y coord-based implementation doesn't allow for that.

---
 pd/nw/pd_canvas.js | 23 +++++++++++++++--------
 pd/nw/pd_menus.js  |  9 ---------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js
index 6dada642e..b9ea297b8 100644
--- a/pd/nw/pd_canvas.js
+++ b/pd/nw/pd_canvas.js
@@ -994,6 +994,21 @@ function create_popup_menu(name) {
             pdgui.popup_action(name, 2);
         }
     }));
+    popup_menu.append(new gui.MenuItem({
+        type: "separator",
+    }));
+    popup_menu.append(new gui.MenuItem({
+        label: "Bring to Front",
+        click: function() {
+            pdgui.popup_action(name, 3);
+        }
+    }));
+    popup_menu.append(new gui.MenuItem({
+        label: "Send to Back",
+        click: function() {
+            pdgui.popup_action(name, 4);
+        }
+    }));
 }
 
 function nw_undo_menu(undo_text, redo_text) {
@@ -1225,14 +1240,6 @@ function nw_create_patch_window_menus(gui, w, name) {
         enabled: true,
         click: function() { pdgui.pdsend(name, "tidy"); }
     });
-    minit(m.edit.tofront, {
-        enabled: true,
-        click: function() { pdgui.popup_action(name, 3); }
-    });
-    minit(m.edit.toback, {
-        enabled: true,
-        click: function() { pdgui.popup_action(name, 4); }
-    });
     minit(m.edit.font, {
         enabled: true,
         click: function () { pdgui.pdsend(name, "menufont"); }
diff --git a/pd/nw/pd_menus.js b/pd/nw/pd_menus.js
index 4f9dc8b48..be925f0f4 100644
--- a/pd/nw/pd_menus.js
+++ b/pd/nw/pd_menus.js
@@ -248,15 +248,6 @@ function create_menu(gui, type) {
             modifiers: cmd_or_ctrl,
             tooltip: l("menu.tidyup_tt")
         }));
-        edit_menu.append(m.edit.tofront = new gui.MenuItem({
-            label: l("menu.tofront"),
-            tooltip: l("menu.tofront_tt")
-        }));
-        edit_menu.append(m.edit.toback = new gui.MenuItem({
-            label: l("menu.toback"),
-            tooltip: l("menu.toback_tt")
-        }));
-        edit_menu.append(new gui.MenuItem({ type: "separator" }));
         edit_menu.append(m.edit.font = new gui.MenuItem({
             label: l("menu.font"),
             tooltip: l("menu.font_tt")
-- 
GitLab