Skip to content

Commit 8c84eba

Browse files
committed
gitk: TIP 474 based mouse wheel support
TIP 474 provides uniform way to handle mouse wheel events for all platforms. > TIP 474: Treat the mouse wheel events in a uniform way > https://core.tcl-lang.org/tips/doc/trunk/tip/474.md TIP 474 was available since Tk 8.7 for development version, and also available since Tk 9.0 for release version. So, use TIP 474 based mouse wheel event handler for all Tk 9 based platforms. Also, adjust horizontal scroll size from 5 to 1 for human eyes. 5 is too big to follow eyes while scrolling. Signed-off-by: YOKOTA Hiroshi <[email protected]>
1 parent 7dd7601 commit 8c84eba

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

gitk

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,27 +2671,42 @@ proc makewindow {} {
26712671
pack .ctop -fill both -expand 1
26722672
bindall <1> {selcanvline %W %x %y}
26732673
#bindall <B1-Motion> {selcanvline %W %x %y}
2674-
if {[tk windowingsystem] == "win32"} {
2675-
bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2676-
bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }
2674+
global have_tk90
2675+
if {$have_tk90} {
2676+
bindall <MouseWheel> {
2677+
set delta [expr {((%D) >= 0) ? -5 : 5}]
2678+
allcanvs yview scroll $delta units
2679+
}
2680+
bindall <Shift-MouseWheel> {
2681+
set delta [expr {((%D) >= 0) ? -1 : 1}]
2682+
$canv xview scroll $delta units
2683+
}
26772684
} else {
2678-
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
2679-
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
2680-
bind $ctext <Button> {
2681-
if {"%b" eq 6} {
2682-
$ctext xview scroll -5 units
2683-
} elseif {"%b" eq 7} {
2684-
$ctext xview scroll 5 units
2685-
}
2686-
}
2687-
if {[tk windowingsystem] eq "aqua"} {
2688-
bindall <MouseWheel> {
2689-
set delta [expr {- (%D)}]
2690-
allcanvs yview scroll $delta units
2691-
}
2692-
bindall <Shift-MouseWheel> {
2693-
set delta [expr {- (%D)}]
2694-
$canv xview scroll $delta units
2685+
switch -- [tk windowingsystem] {
2686+
"win32" {
2687+
bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2688+
bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2689+
}
2690+
"aqua" {
2691+
bindall <MouseWheel> {
2692+
set delta [expr {- (%D)}]
2693+
allcanvs yview scroll $delta units
2694+
}
2695+
bindall <Shift-MouseWheel> {
2696+
set delta [expr {- (%D)}]
2697+
$canv xview scroll $delta units
2698+
}
2699+
}
2700+
"x11" {
2701+
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
2702+
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
2703+
bind $ctext <Button> {
2704+
if {"%b" eq 6} {
2705+
$ctext xview scroll -1 units
2706+
} elseif {"%b" eq 7} {
2707+
$ctext xview scroll 1 units
2708+
}
2709+
}
26952710
}
26962711
}
26972712
}

0 commit comments

Comments
 (0)