(moving to pd-dev...)
On Wed, Sep 28, 2011 at 01:38:54AM -0400, Mathieu Bouchard wrote:
So, if I understand correctly, you are suggesting that these key bindings would only take effect while actively editing the text of an Object, Message, or Comment. If that's the case, +1 -- I agree.
Yes, that's it.
Fortunately, Object, Message and Comment all share the same underlying text entry box implementation, with controls in src/pdtk_text.tcl.
This patch below seems like it ought to at least do something. The "bind" call succeeds, because I've checked and the script fires at each <Return>, and I've looked at other invocations of pdtk_text_editing and these arguments seem correct.
It doesn't work yet, though, and I'm not sure why not -- pdtk_text_editing runs to completion, but running it doesn't seem to accomplish anything.
I'll try again later.
Marvin Humphrey
--- a/tcl/pdtk_text.tcl +++ b/tcl/pdtk_text.tcl @@ -11,6 +11,7 @@ proc pdtk_text_new {tkcanvas tags x y text font_size color} { set mytag [lindex $tags 0] $tkcanvas bind $mytag <Home> "$tkcanvas icursor $mytag 0" $tkcanvas bind $mytag <End> "$tkcanvas icursor $mytag end" + $tkcanvas bind $mytag <Return> "pdtk_text_editing [winfo toplevel $tkcanvas] $mytag 0" # select all $tkcanvas bind $mytag <Triple-ButtonRelease-1> \ "pdtk_text_selectall $tkcanvas $mytag"
Greets,
The emacs keybindings don't seem to be engaging on OS X. If I modify the following line in pdtk_text.tcl, I see the debug print output when I press <Control-a>, confirming that the binding fires -- but the cursor does not move.
if {$::windowingsystem eq "aqua"} { # emacs bindings for Mac OS X - $tkcanvas bind $mytag <Control-a> "$tkcanvas icursor $mytag 0" + $tkcanvas bind $mytag <Control-a> "puts {Checkpoint 1 secured.}; $tkcanvas icursor $mytag 0" $tkcanvas bind $mytag <Control-e> "$tkcanvas icursor $mytag end" }
I suspect this problem is related to why I'm having trouble getting a binding for <Return> to function correctly.
Any ideas on why either $tkcanvas or $mytag would be causing silent failures of these bound scripts?
Marvin Humphrey
Hm, this might point to what Ctrl-A isn't going to Home on Mac OS X.
Basically, this bind command replaces any binding: $tkcanvas bind $mytag <Control-a> "$tkcanvas icursor $mytag 0"
Adding a + to the beginning of the bind function makes it append to the existing list of bindings $tkcanvas bind $mytag <Control-a> "+$tkcanvas icursor $mytag 0"
.hc
On Fri, 2011-09-30 at 09:07 -0700, Marvin Humphrey wrote:
Greets,
The emacs keybindings don't seem to be engaging on OS X. If I modify the following line in pdtk_text.tcl, I see the debug print output when I press <Control-a>, confirming that the binding fires -- but the cursor does not move.
if {$::windowingsystem eq "aqua"} { # emacs bindings for Mac OS X
$tkcanvas bind $mytag <Control-a> "$tkcanvas icursor $mytag 0"
}$tkcanvas bind $mytag <Control-a> "puts {Checkpoint 1 secured.}; $tkcanvas icursor $mytag 0" $tkcanvas bind $mytag <Control-e> "$tkcanvas icursor $mytag end"
I suspect this problem is related to why I'm having trouble getting a binding for <Return> to function correctly.
Any ideas on why either $tkcanvas or $mytag would be causing silent failures of these bound scripts?
Marvin Humphrey
Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
On Fri, Sep 30, 2011 at 12:59:28PM -0400, Hans-Christoph Steiner wrote:
Hm, this might point to what Ctrl-A isn't going to Home on Mac OS X.
Basically, this bind command replaces any binding: $tkcanvas bind $mytag <Control-a> "$tkcanvas icursor $mytag 0"
Adding a + to the beginning of the bind function makes it append to the existing list of bindings $tkcanvas bind $mytag <Control-a> "+$tkcanvas icursor $mytag 0"
OK, that sounds like a good idea in general. (Very few existing invocations of "bind" in the Pd code base are prepended by a "+", FWIW.)
However, in this case, the binding fires successfully, which we know because every time <Control-a> is pressed, we can see the debug print output "Checkpoint 1 secured" in the terminal which was used to launch Pd.
Here's a new variant on the "bind" code again, which adds two debug prints and the prepended "+":
$tkcanvas bind $mytag <Control-a> "+puts {Checkpoint 1 secured.}; $tkcanvas icursor $mytag 0; puts {Checkpoint 2 secured.}"
Here's the relevant output under "pd -stderr -d 3" when <Control-a> gets pressed with that modification in place:
.x10023a3f0 key 1 ?? 0; Checkpoint 1 secured. Checkpoint 2 secured.
.x10023a3f0 key 1 1 0; pdtk_text_set .x10023a3f0.c .x10023a3f0.t10023a630 {food} .x10023a3f0.c select clear .x10023a3f0.c icursor .x10023a3f0.t10023a630 4 .x10023a3f0.c focus .x10023a3f0.t10023a630
.x10023a3f0 key 0 1 0;
.x10023a3f0 key 0 ?? 0;
For some reason, the important part of that script passed to "bind" does not seem to be showing up.
There's an "icursor" invocation in that output, but it originates in src/g_rtext.c in the function rtext_senditup:
sys_vgui(".x%lx.c icursor %s %d\n", canvas, x->x_tag, u8_charnum(x->x_buf, selstart_b));
Maybe that script has to be wrapped in a "pdsend"?
$tkcanvas bind $mytag <Control-a> "+pdsend {$tkcanvas icursor $mytag 0}"
That binding doesn't work, but at least it gets through (note the "error"):
.x10060ee20 key 1 ?? 0;
.x10060ee20.c icursor .x10060ee20.t10060fd20 0; error: .x10060ee20.c: no such object
.x10060ee20 key 1 1 0; pdtk_text_set .x10060ee20.c .x10060ee20.t10060fd20 {food} .x10060ee20.c select clear .x10060ee20.c icursor .x10060ee20.t10060fd20 4 .x10060ee20.c focus .x10060ee20.t10060fd20
.x10060ee20 key 0 1 0;
.x10060ee20 key 0 ?? 0;
Marvin Humphrey
----- Original Message -----
From: Marvin Humphrey marvin@rectangular.com To: Hans-Christoph Steiner hans@at.or.at Cc: pd-dev@iem.at Sent: Saturday, October 1, 2011 3:00 PM Subject: Re: [PD-dev] Text box keybinding silent failure
On Fri, Sep 30, 2011 at 12:59:28PM -0400, Hans-Christoph Steiner wrote:
Hm, this might point to what Ctrl-A isn't going to Home on Mac OS X.
[...]
There's an "icursor" invocation in that output, but it originates in src/g_rtext.c in the function rtext_senditup:
sys_vgui(".x%lx.c icursor %s %d\n", canvas, x->x_tag, u8_charnum(x->x_buf, selstart_b));
Maybe that script has to be wrapped in a "pdsend"?
$tkcanvas bind $mytag <Control-a> "+pdsend {$tkcanvas icursor $mytag 0}"
"icursor" is a tk canvas subcommand, not a pd canvas method:
http://www.tcl.tk/man/tcl8.5/TkCmd/canvas.htm#M44
-Jonathan