$listbox -> unbind ('<Key-Up>');
$listbox -> unbind ('<Key-Down>');
but that didn't remove the binding. Which could be quite possible, as
there are various ways to have an effect happening if a key is pressed.
The problem however, is that $widget -> bind (), only returns non-default
bindings, not the default ones. And while the manpage has a section
named "DEFAULT BINDINGS", that section only describes the effects, not
the implementation. Learning Perl/Tk doesn't describe the bindings either.
How in general would I find out what the current bindings of a widget are,
including the default ones, short of reading the source?
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
Modify the bindtags instead.
> The problem however, is that $widget -> bind (), only returns non-default
> bindings, not the default ones. And while the manpage has a section
> named "DEFAULT BINDINGS", that section only describes the effects, not
> the implementation. Learning Perl/Tk doesn't describe the bindings either.
>
> How in general would I find out what the current bindings of a widget are,
> including the default ones, short of reading the source?
Inspect bindtags, inspect each tag separately. I never remember
how to get bindings of a tag, but each time I ask, somebody
(correctly) replies that it is documented at-this-particular-place
(which I do not remember offhand).
Ilya
...
> Inspect bindtags, inspect each tag separately. I never remember
> how to get bindings of a tag, but each time I ask, somebody
> (correctly) replies that it is documented at-this-particular-place
> (which I do not remember offhand).
TPJ Issue #7 has an article on bind() and bindtags(). There is sample
code to inspect all bindings, etc...
abi...@delanet.com (Abigail) writes:
> Recently, I tried to bind actions to pressing the up/down arrow keys
> in a listbox. That didn't work quite well, as there was already an
> action bound to those keys. So, I tried using
>
> $listbox -> unbind ('<Key-Up>');
> $listbox -> unbind ('<Key-Down>');
>
> but that didn't remove the binding. Which could be quite possible, as
> there are various ways to have an effect happening if a key is pressed.
I believe you can over-ride the default bindings like so:
$listbox -> Tk::bind('Tk::Listbox' => '<Up>' => sub { print "UP!\n" });
To unbind, you set the binding to the empty string.
> The problem however, is that $widget -> bind (), only returns non-default
> bindings, not the default ones. And while the manpage has a section
> named "DEFAULT BINDINGS", that section only describes the effects, not
> the implementation. Learning Perl/Tk doesn't describe the bindings either.
That's why you have to use the global Tk::bind method.
> How in general would I find out what the current bindings of a widget are,
> including the default ones, short of reading the source?
This information belongs in the docs. Unfortunately I don't recall
finding it. I guess the only solution is trial and error for now.
Note that you can play around with the 'bindtags' order. By default,
the order is qw/class instance toplevel all/. You can modify this list
such that all default bindings are removed, and only your defined
bindings are called.
On a related note:
I recently tried to play around with virtual bindings. After spending
some time on it, I dropped it, simply because I couldn't get it to do
what I wanted it to. The reason: I didn't know how to do it!!
The lack of documentation on "advanced" features is seriously
hindering a lot of people. The refguide is great, but not detailed
enough. 'Learning Perl/Tk' is good for beginners only. The man pages
aren't detailed enough either.
I remember vaguely Nick talking about a couple of more Perl/Tk books
in the making. What's the status on that?
Can we organize some group effort to develop an advanced FAQ for
Perl/Tk? (I am aware of the current FAQs).
--Ala
BTW Perl/Tk FAQ: the only FAQ I'm aware of is the one at CPAN
(ptkFAQ-0_03), which is very old (May 1996, pre 800.000 times). Are
there any newer FAQs? Should there be efforts for a new FAQ (which
could also cover advanced questions)?
Regards,
Slaven
--
use Tk;$c=tkinit->Canvas(-he,20)->grid;$x=5;map{s!\n!!g;map{create$c 'line'=>
map{$a=-43+ord;($x+($a>>3)*2=>5+($a&7)*2)}split''}split"!";$x+=12}split/_/=>'K
PI1_+09IPK_K;-OA1_+K!;A__1;Q!7G_1+QK_3CLPI90,_+K!;A_+1!KQ!.N_K+1Q!.F_1+KN.Q__1+
KN._K+1Q!.F_1+KN.Q_+1Q__+1!KQ!.N_1;Q!7G_K3,09Q_+1!K.Q_K+1Q!.F_1+KN.Q_';MainLoop
I am not aware of any other FAQs, and my searches resulted in
ptkFAQ-0_03 only. I am definitely in for another FAQ. If no one else
wants to take care of it, then maybe I can organize it. If interested
drop me a line at aqum...@matrox.com and we'll discuss it further. Any
emails can (and perhaps should) be CCed to the list also.
PS. Sorry for posting from Deja. My newsfeed has problems.
--Ala
--
#!/usr/local/bin/perl -w
# a simple program to print "Just another Perl hacker, "
open _,$0and<_>and$_=<_>and s_.*o __ and eval;
Sent via Deja.com http://www.deja.com/
Before you buy.