toma has asked for the wisdom of the Perl Monks concerning the following question:
It was difficult for me to discover that $e->X and friends did what I wanted.
It seems like the documentation of bind() could use a few more examples in perldoc Tk::bind. There wasn't much in O'Reilly's Mastering Tk along the lines of my code, either.
Am I missing something? Am I writing this code in an unusual way, and perhaps there is another way to do it that has examples in the documentation?
I have been able to find some interesting information by looking at tkBind.c in the pTk source code.
use strict; use warnings; use diagnostics; use Tk; my $mw= MainWindow->new; my $canvas= $mw->Canvas( -background => 'black', -width => '100', -height => '200', )->pack; $canvas->CanvasBind('<Motion>', \&print_coords); &MainLoop; sub print_coords { my ($evt) = @_; my $e= $evt->XEvent; print $e->X,',',$e->Y,' ',$e->x,',',$e->y,"\n"; }
It should work perfectly the first time! - toma
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk event examples?
by PodMaster (Abbot) on Nov 01, 2002 at 08:42 UTC | |
|
Re: Tk event examples?
by Zaxo (Archbishop) on Nov 01, 2002 at 08:30 UTC | |
|
Re: Tk event examples?
by strat (Canon) on Nov 01, 2002 at 12:37 UTC |