in reply to Binding Canvas with MouseWheel
and made a few fixes for that, and your script works with the mousewheel here. What problem do you see?use warnings; use strict;
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $main = $mw -> Scrolled("Canvas",-scrollbars=>'e')-> pack(-side => +'left', -fill => 'both', -expand => 1); my $canvas = $main->Subwidget("canvas"); Tk::bind($canvas, '<MouseWheel>', [ sub {$canvas->yview('scroll',-($_[ +1] / 120) * 3,'units')}, Ev('D')]); my $see = "\nHaaa, See that and die!"; my $info = $main->createText(180, 15, -text => "$see", -font => 'Arial + 11 bold' , -fill => 'red'); $main->configure(-scrollregion => [0,0,2000 , 2000]); my $canvas_cube = $main->Canvas(-width => 15, -height => 15, -backgrou +nd => 'green'); $main ->createWindow(75,75, -window => $canvas_cube); $canvas->focus; MainLoop;
|
|---|