Skip to content

Commit abb97b6

Browse files
committed
gitk: scrolling updates for TclTk 8.7+ / TIP474
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. This means that gitk needs specific bindings only for scrolling the top 3 panes and can use the same bindings on all platforms. TIP 474 provides the delta (%D) value as nominally 120 for a single wheel click, but can be smaller for fine motion. Shift- events are used for horizontal scrolling, and both are connected for the mouse wheel and for touchpads. Also the Option- modifier (the Alt key on PCs, the Option key on Macs) is used to select large rather than fine motion. Button events are never used. 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. So, create a new Tcl9 mouse binding set, based upon win32, but adding Option- bindings that increase scrolling motion by a factor of 5, in keeping with the basic Tk 9.x behavior. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 5518fde commit abb97b6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

gitk

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,22 @@ proc makewindow {} {
26812681
pack .ctop -fill both -expand 1
26822682
bindall <1> {selcanvline %W %x %y}
26832683
#Mouse / touchpad scrolling
2684-
if {[tk windowingsystem] == "win32"} {
2684+
if {[package vcompare $::tcl_version 8.7] >= 0} {
2685+
bindall <MouseWheel> {allcanvs yview scroll [expr -%D*$kscroll/120.] units}
2686+
bindall <Shift-MouseWheel> break
2687+
bind $ctext <MouseWheel> {$ctext yview scroll [expr -%D*$kscroll/120.] units}
2688+
bind $ctext <Shift-MouseWheel> {$ctext xview scroll [expr -%D*$kscroll/120.] units}
2689+
bind $cflist <MouseWheel> {$cflist yview scroll [expr -%D*$kscroll/120.] units}
2690+
bind $cflist <Shift-MouseWheel> {$cflist xview scroll [expr -%D*$kscroll/120.] units}
2691+
bind $canv <Shift-MouseWheel> {$canv xview scroll [expr -%D*$kscroll/120.] units}
2692+
bindall <Alt-MouseWheel> {allcanvs yview scroll [expr -%D*$kscroll/24.] units}
2693+
bindall <Alt-Shift-MouseWheel> break
2694+
bind $ctext <Alt-MouseWheel> {$ctext yview scroll [expr -%D*$kscroll/24.] units}
2695+
bind $ctext <Alt-Shift-MouseWheel> {$ctext xview scroll [expr -%D*$kscroll/24.] units}
2696+
bind $cflist <Alt-MouseWheel> {$cflist yview scroll [expr -%D*$kscroll/24.] units}
2697+
bind $cflist <Alt-Shift-MouseWheel> {$cflist xview scroll [expr -%D*$kscroll/24.] units}
2698+
bind $canv <Alt-Shift-MouseWheel> {$canv xview scroll [expr -%D*$kscroll/24.] units}
2699+
} elseif {[tk windowingsystem] == "win32"} {
26852700
bindall <MouseWheel> {allcanvs yview scroll [expr -%D*$kscroll/120] units}
26862701
bindall <Shift-MouseWheel> break
26872702
bind $ctext <MouseWheel> {$ctext yview scroll [expr -%D*$kscroll/120] units}

0 commit comments

Comments
 (0)