in reply to Tk bindings
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.#!/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__
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 |