Re: Canvas key bindings not working as expected

Jack <[email protected]> Sun, 13 Mar 2011 20:38:07 -0600
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
  On 13/03/2011 1:55 PM, Rainer J.H. Brandt wrote:
> Hello folks,
>
> I'm trying to define bindings to a canvas as a whole.
> That works for mouse buttons, but not for keyboard events.
> I tried this:
>
> use Tk;
>
> $m = MainWindow->new();
> $c = $m->Canvas()->pack();
>
> $c->Tk::bind('<1>' =>  sub { print "button1\n" });
> $c->Tk::bind('<KeyPress-a>' =>  sub { print "key a\n" });
>
> $c->CanvasBind('<2>' =>  sub { print "button2\n" });
> $c->CanvasBind('<KeyPress-b>' =>  sub { print "key b\n" });
>
  $c->Tk::focus;
> MainLoop;
>
>
> Both button bindings work, but neither of the key bindings do.
> This is with Perl 5.12.2 and Perl/Tk 804.029 under Solaris 10
> and Mac OS X Snow Leopard.
>
> Am I overlooking something?
> Thanks,
> Rainer
>
Jack

--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk