in reply to Tk::canvas - Cavas coord problem
use strict; use warnings; use Tk; my $main = new MainWindow; my $c = $main->Canvas( -width => 200, -height => 200, -relief => 'sunken', -borderwidth => 2, )->pack( -expand => 1, -fill => 'both', ); $c->CanvasBind( '<1>' => sub { my ($c) = @_; my $e = $c->XEvent; my $x = $c->canvasx( $e->x ); my $y = $c->canvasy( $e->y ); print "$x,$y\n"; } ); MainLoop;
And it's better not to use Perl's reserved words for variable names or hash keys, in this case 'ref'.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk::canvas - Cavas coord problem
by GenViper (Initiate) on May 12, 2010 at 19:18 UTC |