Skip to content

Commit 45d7aa8

Browse files
committed
gitk: TIP 474 based mouse wheel event handler
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 So, use Tk 9.0 mouse wheel event handler for all platforms. Adjust horizontal scroll size from 5 to 1 for human eyes. 5 is too big. Signed-off-by: YOKOTA Hiroshi <[email protected]>
1 parent c259b2e commit 45d7aa8

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

gitk

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,40 +2702,40 @@ proc makewindow {} {
27022702
pack .ctop -fill both -expand 1
27032703
bindall <1> {selcanvline %W %x %y}
27042704
#bindall <B1-Motion> {selcanvline %W %x %y}
2705-
switch -- [tk windowingsystem] {
2706-
"win32" {
2707-
bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2708-
bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2705+
global have_tk90
2706+
if {$have_tk90} {
2707+
bindall <MouseWheel> {
2708+
set delta [expr {((%D) >= 0) ? -5 : 5}]
2709+
allcanvs yview scroll $delta units
27092710
}
2710-
"aqua" {
2711-
bindall <MouseWheel> {
2712-
set delta [expr {- (%D)}]
2713-
allcanvs yview scroll $delta units
2714-
}
2715-
bindall <Shift-MouseWheel> {
2716-
set delta [expr {- (%D)}]
2717-
$canv xview scroll $delta units
2718-
}
2711+
bindall <Shift-MouseWheel> {
2712+
set delta [expr {((%D) >= 0) ? -1 : 1}]
2713+
$canv xview scroll $delta units
27192714
}
2720-
"x11" {
2721-
global have_tk90
2722-
if {$have_tk90} {
2715+
} else {
2716+
switch -- [tk windowingsystem] {
2717+
"win32" {
2718+
bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2719+
bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2720+
}
2721+
"aqua" {
27232722
bindall <MouseWheel> {
2724-
set delta [expr {((%D) >= 0) ? -5 : 5}]
2723+
set delta [expr {- (%D)}]
27252724
allcanvs yview scroll $delta units
27262725
}
27272726
bindall <Shift-MouseWheel> {
2728-
set delta [expr {((%D) >= 0) ? -5 : 5}]
2727+
set delta [expr {- (%D)}]
27292728
$canv xview scroll $delta units
27302729
}
2731-
} else {
2730+
}
2731+
"x11" {
27322732
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
27332733
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
27342734
bind $ctext <Button> {
27352735
if {"%b" eq 6} {
2736-
$ctext xview scroll -5 units
2736+
$ctext xview scroll -1 units
27372737
} elseif {"%b" eq 7} {
2738-
$ctext xview scroll 5 units
2738+
$ctext xview scroll 1 units
27392739
}
27402740
}
27412741
}

0 commit comments

Comments
 (0)