in reply to Tk bindings

A possible solution is to get the old value of the binding and fire this callback in the new callback. E.g.
#!/usr/bin/perl use Tk; $mw = tkinit; $mw->bind("<Return>" => sub { warn "Old binding" }); my $old_binding = $mw->bind("<Return>"); $mw->bind("<Return>" => sub { $old_binding->Call(); warn "New binding" }); MainLoop; __END__
Note that the return value of bind is not a CODE reference, but a Tk::Callback object, so you have to use the Call() method.

It's also possible to add a new bindtag via the bindtags() method:

#!/usr/bin/perl use Tk; $mw = tkinit; $mw->bind("<Return>" => sub { warn "Old binding" }); $mw->bind("anotherbindtag", "<Return>" => sub { warn "New binding" }); $mw->bindtags(["anotherbindtag", $mw->bindtags]); MainLoop; __END__

Replies are listed 'Best First'.
Re: Re: Tk bindings
by eric256 (Parson) on May 19, 2004 at 16:38 UTC

    Thanks your second solution was great. Thats a great way for controls that have subwidgets to bind stuff on those subwidgets without messing up the original bindings. I've fired off an email to the author so hopefully it will all get fixed up! Thanks!


    ___________
    Eric Hodges