From 10ec8722bd122f68d85e2593bc02d911bacc9730 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Tue, 29 Dec 2015 17:28:13 -0500
Subject: [PATCH] set the editmode checkbox in menu when the patch gets created

---
 pd/nw/pd_canvas.js | 3 ++-
 pd/nw/pdgui.js     | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js
index faf860f62..608da223a 100644
--- a/pd/nw/pd_canvas.js
+++ b/pd/nw/pd_canvas.js
@@ -627,7 +627,7 @@ var canvas_events = (function() {
 // This gets called from the nw_create_window function in index.html
 // It provides us with our canvas id from the C side.  Once we have it
 // we can create the menu and register event callbacks
-function register_canvas_id(cid) {
+function register_canvas_id(cid, attr_array) {
     name = cid; // hack
     // We create the window menus and popup menu before doing anything else
     // to ensure that we don't try to set the svg size before these are done.
@@ -646,6 +646,7 @@ function register_canvas_id(cid) {
     nw_window_focus_callback();
     canvas_events.normal();
     pdgui.canvas_map(cid); // side-effect: triggers gui_canvas_getscroll from Pd
+    set_editmode_checkbox(attr_array.editmode !== 0 ? true : false);
 }
 
 function create_popup_menu(name) {
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 0a30bfb76..b30d4804b 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -888,7 +888,7 @@ function gui_canvas_set_title(cid, name, args, dir, dirty_flag) {
 
 // create a new canvas
 // todo: rename parameter "name" to "cid"
-function gui_canvas_new(cid, width, height, geometry, editable, name, dir, dirty_flag, cargs) {
+function gui_canvas_new(cid, width, height, geometry, editmode, name, dir, dirty_flag, cargs) {
     // hack for buggy tcl popups... should go away for node-webkit
     //reset_ctrl_on_popup_window
 
@@ -937,7 +937,8 @@ function gui_canvas_new(cid, width, height, geometry, editable, name, dir, dirty
             name: name,
             dir: dir,
             dirty: dirty_flag,
-            args: cargs
+            args: cargs,
+            editmode: editmode
     });
     // initialize variable to reflect that this window has been opened
     loaded[cid] = 1;
-- 
GitLab