-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBindMouseWheel.pl
97 lines (87 loc) · 2.06 KB
/
BindMouseWheel.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/local/bin/perl -w
sub BindMouseWheel
{
my($w) = @_;
if ($^O eq 'MSWin32') #BUMMER!:
{
$w->bind('<MouseWheel>' =>
[ sub { $_[0]->yview('scroll', -($_[1] / 120) * 1, '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:
#
# Section "InputDevice"
# Identifier "Mouse0"
# Driver "mouse"
# Option "Device" "/dev/mouse"
# Option "Protocol" "IMPS/2"
# Option "Emulate3Buttons" "off"
# Option "ZAxisMapping" "4 5"
# EndSection
#DEPRECIATED: $w->bind('<Alt-Left>' => sub
#DEPRECIATED: {
#DEPRECIATED: $_[0]->xview('scroll', -1, 'units');
#DEPRECIATED: Tk->break;
#DEPRECIATED: }
#DEPRECIATED: );
#DEPRECIATED: $w->bind('<Alt-Right>' => sub
#DEPRECIATED: {
#DEPRECIATED: $_[0]->xview('scroll', +1, 'units');
#DEPRECIATED: Tk->break;
#DEPRECIATED: }
#DEPRECIATED: );
#NEXT 2 ALLOW HORIZONTAL SCROLLING ON SINGLE-WHEEL MOUSE (Alt-Wheel):
$w->bind('<Alt-Button-4>' => sub
{
$_[0]->xview('scroll', -1, 'units');
Tk->break;
}
);
$w->bind('<Alt-Button-5>' => sub
{
$_[0]->xview('scroll', +1, 'units');
Tk->break;
}
);
$w->bind('<Shift-Button-4>' => sub
{
$_[0]->yview('scroll', -1, 'pages') unless $Tk::strictMotif;
Tk->break;
}
);
$w->bind('<Shift-Button-5>' => sub
{
$_[0]->yview('scroll', +1, 'pages') unless $Tk::strictMotif;
Tk->break;
}
);
$w->bind('<Button-4>' => sub
{
$_[0]->yview('scroll', -1, 'units') unless $Tk::strictMotif;
}
);
$w->bind('<Button-5>' => sub
{
$_[0]->yview('scroll', +1, 'units') unless $Tk::strictMotif;
}
);
$w->bind('<Button-6>' => sub
{
$_[0]->xview('scroll', -1, 'units') unless $Tk::strictMotif;
}
);
$w->bind('<Button-7>' => sub
{
$_[0]->xview('scroll', +1, 'units') unless $Tk::strictMotif;
}
);
}
} # end BindMouseWheel
1