On Tue, Sep 27, 2011 at 11:50:07AM -0400, Mathieu Bouchard wrote:
Le 2011-09-25 à 09:29:00, Marvin Humphrey a écrit :
The patch below fixes the problem. I don't know if it's the right solution, though.
Pd doesn't _have_ to pass keynums around like that. If the Tk code were
sending Up/Down/Left/Right names as given by Tk's bind's %K (uppercase),
then you wouldn't have to replicate in g_editor.c things that Tk already
does as part of its portability layer.
Ha, interesting.
The patch below, which also achieves correct behavior of cursor keys under Snow Leopard, is an alternative to the patch supplied earlier. This one has the advantage of removing the "#ifdef __APPLE__" code from src/g_editor.c, as the normalization is now achieved via Tk. However, I don't yet understand all the ramifications, just as I did not with the last patch.
Marvin Humphrey
From 08d585e6f4d9158f94edc8896de80a3635bb717f Mon Sep 17 00:00:00 2001
From: Marvin Humphrey marvin@rectangular.com Date: Tue, 27 Sep 2011 19:57:13 -0700 Subject: [PATCH] Normalize cursor key behavior at the Tcl level.
Take advantage of Tk's portability layer for normalizing cursor key values instead of reproducing it ourselves at the C level.
src/g_editor.c | 10 ---------- tcl/pd_bindings.tcl | 4 ++++ 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/g_editor.c b/src/g_editor.c index f494732..983f463 100644 --- a/src/g_editor.c +++ b/src/g_editor.c @@ -1699,16 +1699,6 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) keyupsym = gensym("#keyup"); keynamesym = gensym("#keyname"); } -#ifdef __APPLE__
if (keynum == 30)
keynum = 0, gotkeysym = gensym("Up");
else if (keynum == 31)
keynum = 0, gotkeysym = gensym("Down");
else if (keynum == 28)
keynum = 0, gotkeysym = gensym("Left");
else if (keynum == 29)
keynum = 0, gotkeysym = gensym("Right");
-#endif if (keynumsym->s_thing && down) pd_float(keynumsym->s_thing, (t_float)keynum); if (keyupsym->s_thing && !down) diff --git a/tcl/pd_bindings.tcl b/tcl/pd_bindings.tcl index 82ac350..cff0bbc 100644 --- a/tcl/pd_bindings.tcl +++ b/tcl/pd_bindings.tcl @@ -249,6 +249,10 @@ proc ::pd_bindings::sendkey {window state key iso shift} { "Tab" { set iso ""; set key 9 } "Return" { set iso ""; set key 10 } "Escape" { set iso ""; set key 27 }
"Left" { set iso ""; set key 28 }
"Right" { set iso ""; set key 29 }
"Up" { set iso ""; set key 30 }
"Down" { set iso ""; set key 31 }
"Space" { set iso ""; set key 32 }
"Delete" { set iso ""; set key 127 }
"KP_Delete" { set iso ""; set key 127 }