Skip to content

Commit 6ea3006

Browse files
committed
gitk: update scrolling for TclTk 8.7+ / TIP 474
TclTk 8.7 (still in alpha), and 9.0 (released), implement TIP 474 that delivers uniform handling of mouse and touchpad scrolling events on all platforms, and by default bound to most widgets. TIP 474 also implements use of the Option- modifier key (Alt- key on PC, Option- key on Macs) to indicate desire for more motion per scroll wheel event, the amplification is not defined but seems to be 5x to 10x. So, for TclTk >= 8.7 we can use identical MouseWheel bindings on all platforms, and should enable use of the Option- modifier to enable larger motion. Let's do all of this, and use a 5x multiplier for the Option- modifier. This largely follows the prior win32 model, except that Tk 8.6 does not reliably use the Option- modifier because the Alt- key conflicts with builtin behavior to activate the main menubar. Presumably this conflict is addressed in the win32 Tcl9.x package. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 3e43143 commit 6ea3006

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

gitk

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,16 @@ proc bind_mousewheel {} {
22732273
bind $cflist <MouseWheel> {$cflist yview scroll [scrollval %D 2] units}
22742274
bind $cflist <Shift-MouseWheel> break
22752275
bind $canv <Shift-MouseWheel> {$canv xview scroll [scrollval %D] units}
2276+
2277+
if {[package vcompare $::tcl_version 8.7] >= 0} {
2278+
bindall <Alt-MouseWheel> {allcanvs yview scroll [scrollval 5*%D] units}
2279+
bindall <Alt-Shift-MouseWheel> break
2280+
bind $ctext <Alt-MouseWheel> {$ctext yview scroll [scrollval 5*%D 2] units}
2281+
bind $ctext <Alt-Shift-MouseWheel> {$ctext xview scroll [scrollval 5*%D 2] units}
2282+
bind $cflist <Alt-MouseWheel> {$cflist yview scroll [scrollval 5*%D 2] units}
2283+
bind $cflist <Alt-Shift-MouseWheel> break
2284+
bind $canv <Alt-Shift-MouseWheel> {$canv xview scroll [scrollval 5*%D] units}
2285+
}
22762286
}
22772287
22782288
proc bind_mousewheel_buttons {} {
@@ -2732,7 +2742,7 @@ proc makewindow {} {
27322742
bindall <1> {selcanvline %W %x %y}
27332743
27342744
#Mouse / touchpad scrolling
2735-
if {[tk windowingsystem] == "win32"} {
2745+
if {[tk windowingsystem] == "win32" || [package vcompare $::tcl_version 8.7] >= 0} {
27362746
set scroll_D0 120
27372747
bind_mousewheel
27382748
} elseif {[tk windowingsystem] == "x11"} {

0 commit comments

Comments
 (0)