summaryrefslogtreecommitdiffstats
path: root/library/scrlbar.tcl
diff options
context:
space:
mode:
authorcsaba <csaba>2023-12-01 12:26:57 (GMT)
committercsaba <csaba>2023-12-01 12:26:57 (GMT)
commit39ed53bbb13ea433f0663adea0ab5b1c3613acdd (patch)
tree84f738bf42673ac57dd170d289d41929cc813497 /library/scrlbar.tcl
parent04772f4b2d2d872ff63c509b26f63bb72e18749b (diff)
downloadtk-39ed53bbb13ea433f0663adea0ab5b1c3613acdd.zip
tk-39ed53bbb13ea433f0663adea0ab5b1c3613acdd.tar.gz
tk-39ed53bbb13ea433f0663adea0ab5b1c3613acdd.tar.bz2
For X11 only: Minimize the number of artifacts caused by intermixed <MouseWheel> and <Shift-MouseWheel> events triggered by two-finger gestures.
Diffstat (limited to 'library/scrlbar.tcl')
-rw-r--r--library/scrlbar.tcl33
1 files changed, 27 insertions, 6 deletions
diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl
index 5c4ba72..3d3f204 100644
--- a/library/scrlbar.tcl
+++ b/library/scrlbar.tcl
@@ -129,14 +129,21 @@ bind Scrollbar <<LineEnd>> {
}
}
-bind Scrollbar <Option-MouseWheel> {
- tk::ScrollByUnits %W hv %D -12.0
+bind Scrollbar <Enter> {+
+ set tk::Priv(xEvents) 0; set tk::Priv(yEvents) 0
}
-
bind Scrollbar <MouseWheel> {
+ tk::ScrollByUnits %W vh %D -40.0
+}
+bind Scrollbar <Option-MouseWheel> {
+ tk::ScrollByUnits %W vh %D -12.0
+}
+bind Scrollbar <Shift-MouseWheel> {
tk::ScrollByUnits %W hv %D -40.0
}
-
+bind Scrollbar <Shift-Option-MouseWheel> {
+ tk::ScrollByUnits %W hv %D -12.0
+}
bind Scrollbar <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
if {$deltaX != 0 && [%W cget -orient] eq "horizontal"} {
@@ -147,7 +154,6 @@ bind Scrollbar <TouchpadScroll> {
}
}
-
# tk::ScrollButtonDown --
# This procedure is invoked when a button is pressed in a scrollbar.
# It changes the way the scrollbar is displayed and takes actions
@@ -358,7 +364,7 @@ proc ::tk::ScrollbarScrollByPixels {w orient amount} {
# Arguments:
# w - The scrollbar widget.
# orient - Which kinds of scrollbars this applies to: "h" for
-# horizontal, "v" for vertical, "hv" for both.
+# horizontal, "v" for vertical, "hv" or "vh" for both.
# amount - How many units to scroll: typically 1 or -1.
proc ::tk::ScrollByUnits {w orient amount {factor 1.0}} {
@@ -367,6 +373,21 @@ proc ::tk::ScrollByUnits {w orient amount {factor 1.0}} {
[string index [$w cget -orient] 0] $orient] < 0)} {
return
}
+
+ if {[string length $orient] == 2 && $factor != 1.0} {
+ # Count both the <MouseWheel> and <Shift-MouseWheel>
+ # events, and ignore the non-dominant ones
+
+ variable ::tk::Priv
+ set axis [expr {[string index $orient 0] eq "h" ? "x" : "y"}]
+ incr Priv(${axis}Events)
+ if {($Priv(xEvents) + $Priv(yEvents) > 10) &&
+ ($axis eq "x" && $Priv(xEvents) < $Priv(yEvents) ||
+ $axis eq "y" && $Priv(yEvents) < $Priv(xEvents))} {
+ return
+ }
+ }
+
set info [$w get]
if {[llength $info] == 2} {
uplevel #0 $cmd scroll [expr {$amount/$factor}] units