[PD-dev] Text box keybinding silent failure

Marvin Humphrey marvin at rectangular.com
Sat Oct 1 21:00:50 CEST 2011


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




More information about the Pd-dev mailing list