summaryrefslogtreecommitdiffstats
path: root/library/ttk
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/ttk
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/ttk')
-rw-r--r--library/ttk/combobox.tcl2
-rw-r--r--library/ttk/notebook.tcl46
-rw-r--r--library/ttk/scrollbar.tcl14
-rw-r--r--library/ttk/spinbox.tcl3
4 files changed, 50 insertions, 15 deletions
diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl
index 449d0a2..c253eb0 100644
--- a/library/ttk/combobox.tcl
+++ b/library/ttk/combobox.tcl
@@ -52,7 +52,7 @@ bind TCombobox <Triple-Button-1> { ttk::combobox::Press "3" %W %x %y }
bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x }
bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y }
-ttk::bindMouseWheel TCombobox [list ttk::combobox::Scroll %W]
+ttk::bindMouseWheel TCombobox { ttk::combobox::Scroll %W }
bind TCombobox <Shift-MouseWheel> {
# Ignore the event
}
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl
index b3acf3f..7fb0ad5 100644
--- a/library/ttk/notebook.tcl
+++ b/library/ttk/notebook.tcl
@@ -16,14 +16,25 @@ bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break }
}
bind TNotebook <Destroy> { ttk::notebook::Cleanup %W }
-ttk::bindMouseWheel TNotebook [list ttk::notebook::CycleTab %W]
+bind TNotebook <Enter> {
+ set tk::Priv(xEvents) 0; set tk::Priv(yEvents) 0
+}
+bind TNotebook <MouseWheel> {
+ ttk::notebook::CondCycleTab1 %W y %D -120.0
+}
+bind TNotebook <Option-MouseWheel> {
+ ttk::notebook::CondCycleTab1 %W y %D -12.0
+}
bind TNotebook <Shift-MouseWheel> {
- # Ignore the event
+ ttk::notebook::CondCycleTab1 %W x %D -120.0
+}
+bind TNotebook <Shift-Option-MouseWheel> {
+ ttk::notebook::CondCycleTab1 %W x %D -12.0
}
bind TNotebook <TouchpadScroll> {
# TouchpadScroll events fire about 60 times per second.
if {[expr {%# %% 30}] == 0} {
- ttk::notebook::CondCycleTab %W %D
+ ttk::notebook::CondCycleTab2 %W %D
}
}
@@ -84,10 +95,28 @@ proc ttk::notebook::CycleTab {w dir {factor 1.0}} {
}
}
-# CondCycleTab --
+# CondCycleTab1 --
+# Conditionally invoke the ttk::notebook::CycleTab proc.
+#
+proc ttk::notebook::CondCycleTab1 {w axis dir {factor 1.0}} {
+ # Count both the <MouseWheel> and <Shift-MouseWheel>
+ # events, and ignore the non-dominant ones
+
+ variable ::tk::Priv
+ 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
+ }
+
+ CycleTab $w $dir $factor
+}
+
+# CondCycleTab2 --
# Conditionally invoke the ttk::notebook::CycleTab proc.
#
-proc ttk::notebook::CondCycleTab {w dxdy} {
+proc ttk::notebook::CondCycleTab2 {w dxdy} {
if {[set style [$w cget -style]] eq ""} {
set style TNotebook
}
@@ -95,10 +124,9 @@ proc ttk::notebook::CondCycleTab {w dxdy} {
lassign [tk::PreciseScrollDeltas $dxdy] deltaX deltaY
if {$tabSide in {n s} && $deltaX != 0} {
- CycleTab $w [expr {$deltaX > 0 ? -1 : 1}]
- }
- if {$tabSide in {w e} && $deltaY != 0} {
- CycleTab $w [expr {$deltaY > 0 ? -1 : 1}]
+ CycleTab $w [expr {$deltaX < 0 ? -1 : 1}]
+ } elseif {$tabSide in {w e} && $deltaY != 0} {
+ CycleTab $w [expr {$deltaY < 0 ? -1 : 1}]
}
}
diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl
index 28c6a84..7c31511 100644
--- a/library/ttk/scrollbar.tcl
+++ b/library/ttk/scrollbar.tcl
@@ -17,11 +17,17 @@ bind TScrollbar <Button-2> { ttk::scrollbar::Jump %W %x %y }
bind TScrollbar <B2-Motion> { ttk::scrollbar::Drag %W %x %y }
bind TScrollbar <ButtonRelease-2> { ttk::scrollbar::Release %W %x %y }
-# Redirect scrollwheel bindings to the scrollbar widget
+# Copy the mouse wheel event bindings from Scrollbar to TScrollbar
#
-bind TScrollbar <MouseWheel> [bind Scrollbar <MouseWheel>]
-bind TScrollbar <Option-MouseWheel> [bind Scrollbar <Option-MouseWheel>]
-bind TScrollbar <TouchpadScroll> [bind Scrollbar <TouchpadScroll>]
+bind TScrollbar <Enter> {
+ set tk::Priv(xEvents) 0; set tk::Priv(yEvents) 0
+}
+foreach event {<MouseWheel> <Option-MouseWheel>
+ <Shift-MouseWheel> <Shift-Option-MouseWheel>
+ <TouchpadScroll>} {
+ bind TScrollbar $event [bind Scrollbar $event]
+}
+unset event
proc ttk::scrollbar::Scroll {w n units} {
set cmd [$w cget -command]
diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl
index 252521a..0160d35 100644
--- a/library/ttk/spinbox.tcl
+++ b/library/ttk/spinbox.tcl
@@ -23,12 +23,13 @@ bind TSpinbox <Down> { event generate %W <<Decrement>> }
bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 }
bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 }
-ttk::bindMouseWheel TSpinbox [list ttk::spinbox::Spin %W]
+ttk::bindMouseWheel TSpinbox { ttk::spinbox::Spin %W }
bind TSpinbox <Shift-MouseWheel> {
# Ignore the event
}
bind TSpinbox <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ # TouchpadScroll events fire about 60 times per second.
if {$deltaY != 0 && [expr {%# %% 12}] == 0} {
ttk::spinbox::Spin %W [expr {$deltaY > 0 ? -1 : 1}]
}