Home > Archive > PerlTk > October 2007 > Binding internals
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| dmpetit 2007-09-27, 7:06 pm |
| Hello,
YASQ (Yet another simple question)
Does someone the C code to look into about how a binding for a class given
in ClassInit goes at head for a instance of that class ?
Regards.
| |
| smallpond 2007-09-28, 7:06 pm |
| On Sep 27, 1:21 pm, dmpetit <dmpe...@free.fr> wrote:
> Hello,
>
> YASQ (Yet another simple question)
>
> Does someone the C code to look into about how a binding for a class given
> in ClassInit goes at head for a instance of that class ?
>
> Regards.
No need for the C code. From the docs for Tk::bindtags:
"By default, each window has four binding tags consisting of the
window's class name, name of the window, the name of the window's
nearest toplevel ancestor, and 'all', in that order. Toplevel
windows have only three tags by default, since the toplevel name
is the same as that of the window."
"The bindtags command allows the binding tags for a window to be
read and modified."
Steve Lidie's example code to reorder:
my $frog = $mw->Button(-text => 'FunnyButton')->pack;
my (@frog_bindtags) = $frog->bindtags;
print "frog_bindtags=@frog_bindtags!\n";
# Reorder FunnyButton bindtags: instance class toplevel all
$frog->bindtags( [ @frog_bindtags[1, 0, 2, 3] ] );
--S
| |
| dmpetit 2007-10-01, 7:09 pm |
|
> On Sep 27, 1:21 pm, dmpetit <dmpe...@free.fr> wrote:
>
> No need for the C code. From the docs for Tk::bindtags:
>
> "By default, each window has four binding tags consisting of the
> window's class name, name of the window, the name of the window's
> nearest toplevel ancestor, and 'all', in that order. Toplevel
> windows have only three tags by default, since the toplevel name
> is the same as that of the window."
>
> "The bindtags command allows the binding tags for a window to be
> read and modified."
>
> Steve Lidie's example code to reorder:
>
> my $frog = $mw->Button(-text => 'FunnyButton')->pack;
> my (@frog_bindtags) = $frog->bindtags;
> print "frog_bindtags=@frog_bindtags!\n";
> # Reorder FunnyButton bindtags: instance class toplevel all
> $frog->bindtags( [ @frog_bindtags[1, 0, 2, 3] ] );
>
> --S
This is the YASR to the YASQ ! Of course, I know well that and did not
thought that a so simple question could be left to that newsgroup.
Still, the question is : How.
Now, after some reverse engenereeing, I got part of the answser: you are
correct, C code is not where the magic works; or, yes, the magic in the C
code is superseded by perl glue code, as follows :
In the perl function new in Widget.pm, after call to C glue code throught
$cmd, is the call to SetBindtags with the new object, meaning that :
* after C code, bindings are as tcl/tck order (aswer is no);
* after Perl code, bindings are redefined (answer is yes);
In other words, perl does the job, not C code. The tag 'scope' vs the
binding 'scope' were not very well defined/clear to me.
In my opinion, the scope of a tag is toplevel window, the scope of a binding
is anywhere a tag can apply (for a given event, of course). To remove a
particular binding, don't bind to undef : create a tag and set bindtags as
needed.
But still, these assumptions should be fixed by code reading and/or
documentation between the lines reading.
|
|
|
|
|