#!/usr/bin/perl use Tk; my $mw = MainWindow->new(); $mw->geometry("600x400+100+100"); $canvas = $mw->Canvas(width => 600, height => 400)->pack(); $canvas->Tk::bind("", [ \&print_xy, Ev('x'), Ev('y') ]); # This draws half of an oval $oval = $canvas->createOval(100,100,200,250,-fill => 'white',-tags => "blue"); $canvas->Tk::bind("", sub {$canvas->itemconfigure($oval,-fill => "red")}); $canvas->bind('blue', '', sub { $canvas->itemconfigure("blue", -fill => "blue"); } ); # sub {exit}); # When the mouse is not over, color it black. $canvas->bind("blue", "", sub { $canvas->itemconfigure("blue", -fill => "black"); }); #$tw->tagBind('tag','',sub{$overtag=1}); MainLoop; sub print_xy { print "@_\n"; my ($canv, $x, $y) = @_; print "(x,y) = ", $canv->canvasx($x), ", ", $canv->canvasy($y), "\n"; }