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;