From 6fbc5a11c8e9d46c612de73557a012357c40c79a Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Fri, 6 Dec 2013 20:53:38 -0500
Subject: [PATCH] *added dynamic switching of the edit menu buttons

---
 pd/src/g_editor.c | 4 +++-
 pd/src/pd.tk      | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 5d8dcff85..94068132e 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -4545,9 +4545,11 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
 	{
 		//fprintf(stderr,"ctrl\n");
 		glob_ctrl = down;
-		if(x->gl_edit && x->gl_editor->e_onmotion == MA_NONE)
+		if(x->gl_edit && x->gl_editor->e_onmotion == MA_NONE) {
         	canvas_setcursor(x, down ?
             	CURSOR_RUNMODE_NOTHING : CURSOR_EDITMODE_NOTHING);
+        	sys_vgui("pdtk_canvas_editval .x%lx %d\n", (t_int)x, down ? 0 : 1);
+        }
 	}
 	//fprintf(stderr," %d %d %d %s %d %d\n", glob_shift, glob_ctrl, glob_alt, gotkeysym->s_name, keynum, down);
 	//canvas_motion(x, canvas_last_glist_x, canvas_last_glist_y, canvas_last_glist_mod);
diff --git a/pd/src/pd.tk b/pd/src/pd.tk
index cb6284da1..bc015c707 100644
--- a/pd/src/pd.tk
+++ b/pd/src/pd.tk
@@ -2494,6 +2494,8 @@ proc pdtk_canvas_new {name width height geometry editable} {
 		pack $name.k12frame.edit.b -side left -expand 1 -padx 1 -pady 0
 		setTooltip $name.k12frame.edit.b "Toggle between building and playing an instrument"
 		pdtk_standardkeybindings $name.k12frame.edit.b
+		bind $name.k12frame.edit.b <Key> [list pdtk_canvas_sendkey $name.c 1 %K %A 0 1 %t]
+    	bind $name.k12frame.edit.b <KeyRelease> [list pdtk_canvas_sendkey $name.c 0 %K %A 0 1 %t]
 
 		# ---------------------------------- DATA VS SOUND BUTTONS ----------------------------------
 		match_linux_wm [list frame $name.k12frame.datasound -relief flat]
-- 
GitLab