sub BindMouseWheel {
my ($w) = @_;
if ($^O eq "MSWin32")
{
$w->bind('<MouseWheel>' => [ sub { $_[0]->yview('scroll', -($_[1]/120)*3, 'units') }, Ev('D') ] );
}
else
{
# Support for mousewheels on Linux commonly comes through
# mapping the wheel to buttons 4 and 5. If you have a
# mousewheel ensure that the mouse protocol is set to
# "IMPS/2" in your /etc/X11/XF86Config (or XF86Config-4)
# file:
# Select "InputDevice"
# Identifier "Mouse0"
# Driver "mouse"
# Option "Device" "/dev/mouse"
# Option "Protocol" "IMPS/2"
# Option "Emulate3Buttons" "off"
# Option "ZAxisMapping" "4 5"
# EndSection
$w->bind('<4>', => sub {
$_[0]->yview('scroll', -3, 'units') unless $Tk::strictMotif;
});
$w->bind('<5>' => sub {
$_[0]->yview('scroll', +3, 'units') unless $Tk::strictMotif;
});
}
}