summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorcsaba <csaba>2023-12-12 15:31:24 (GMT)
committercsaba <csaba>2023-12-12 15:31:24 (GMT)
commiteb5378812e0953cf7516d8a3b8783d22ccc6c6e6 (patch)
tree087d62d91c098809c90ed3036e48e219ac988ce0 /library
parenta71e712859d7f6c9977360f11e274472cfb0633f (diff)
downloadtk-eb5378812e0953cf7516d8a3b8783d22ccc6c6e6.zip
tk-eb5378812e0953cf7516d8a3b8783d22ccc6c6e6.tar.gz
tk-eb5378812e0953cf7516d8a3b8783d22ccc6c6e6.tar.bz2
Made the scrolling by units via <TouchpadScroll> smoother.
Diffstat (limited to 'library')
-rw-r--r--library/listbox.tcl2
-rw-r--r--library/tk.tcl29
-rw-r--r--library/ttk/combobox.tcl2
-rw-r--r--library/ttk/notebook.tcl2
-rw-r--r--library/ttk/spinbox.tcl2
-rw-r--r--library/ttk/utils.tcl2
6 files changed, 20 insertions, 19 deletions
diff --git a/library/listbox.tcl b/library/listbox.tcl
index 3beeaa4..d611801 100644
--- a/library/listbox.tcl
+++ b/library/listbox.tcl
@@ -188,7 +188,7 @@ bind Listbox <Shift-Option-MouseWheel> {
tk::MouseWheel %W x %D -12.0 units
}
bind Listbox <TouchpadScroll> {
- if {[expr {%# %% 15}] != 0} {
+ if {%# %% 5 != 0} {
return
}
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
diff --git a/library/tk.tcl b/library/tk.tcl
index e6e1ce2..26ab1cc 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -550,6 +550,7 @@ proc ::tk::MouseWheel {w dir amount {factor -120.0} {units units}} {
}
## ::tk::PreciseScrollDeltas $dxdy
+
proc ::tk::PreciseScrollDeltas {dxdy} {
set deltaX [expr {$dxdy >> 16}]
set low [expr {$dxdy & 0xffff}]
@@ -557,6 +558,20 @@ proc ::tk::PreciseScrollDeltas {dxdy} {
return [list $deltaX $deltaY]
}
+# Helper for smooth scrolling of widgets that support xview moveto,
+# yview moveto, height and width.
+
+proc ::tk::ScrollByPixels {w deltaX deltaY} {
+ set width [expr {1.0 * [$w cget -width]}]
+ set height [expr {1.0 * [$w cget -height]}]
+ set X [lindex [$w xview] 0]
+ set Y [lindex [$w yview] 0]
+ set x [expr {$X - $deltaX / $width}]
+ set y [expr {$Y - $deltaY / $height}]
+ $w xview moveto $x
+ $w yview moveto $y
+}
+
# ::tk::TabToWindow --
# This procedure moves the focus to the given widget.
# It sends a <<TraverseOut>> virtual event to the previous focus window,
@@ -845,20 +860,6 @@ if {$::ttk::library ne ""} {
uplevel \#0 [list source -encoding utf-8 $::ttk::library/ttk.tcl]
}
-# Helper for smooth scrolling of widgets that support xview moveto,
-# yview moveto, height and width.
-
-proc ::tk::ScrollByPixels {w deltaX deltaY} {
- set width [expr {1.0 * [$w cget -width]}]
- set height [expr {1.0 * [$w cget -height]}]
- set X [lindex [$w xview] 0]
- set Y [lindex [$w yview] 0]
- set x [expr {$X - $deltaX / $width}]
- set y [expr {$Y - $deltaY / $height}]
- $w xview moveto $x
- $w yview moveto $y
-}
-
# Local Variables:
# mode: tcl
diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl
index c253eb0..1b9d4cb 100644
--- a/library/ttk/combobox.tcl
+++ b/library/ttk/combobox.tcl
@@ -59,7 +59,7 @@ bind TCombobox <Shift-MouseWheel> {
bind TCombobox <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
# TouchpadScroll events fire about 60 times per second.
- if {$deltaY != 0 && [expr {%# %% 15}] == 0} {
+ if {$deltaY != 0 && %# %% 15 == 0} {
ttk::combobox::Scroll %W [expr {$deltaY > 0 ? -1 : 1}]
}
}
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl
index 55aaa03..1d59d1e 100644
--- a/library/ttk/notebook.tcl
+++ b/library/ttk/notebook.tcl
@@ -33,7 +33,7 @@ bind TNotebook <Shift-Option-MouseWheel> {
}
bind TNotebook <TouchpadScroll> {
# TouchpadScroll events fire about 60 times per second.
- if {[expr {%# %% 30}] == 0} {
+ if {%# %% 15 == 0} {
ttk::notebook::CondCycleTab2 %W %D
}
}
diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl
index 0160d35..96d8acf 100644
--- a/library/ttk/spinbox.tcl
+++ b/library/ttk/spinbox.tcl
@@ -30,7 +30,7 @@ bind TSpinbox <Shift-MouseWheel> {
bind TSpinbox <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
# TouchpadScroll events fire about 60 times per second.
- if {$deltaY != 0 && [expr {%# %% 12}] == 0} {
+ if {$deltaY != 0 && %# %% 12 == 0} {
ttk::spinbox::Spin %W [expr {$deltaY > 0 ? -1 : 1}]
}
}
diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl
index 9b15eb6..3f6446d 100644
--- a/library/ttk/utils.tcl
+++ b/library/ttk/utils.tcl
@@ -304,7 +304,7 @@ bind TtkScrollable <Shift-Option-MouseWheel> \
## Touchpad scrolling
#
bind TtkScrollable <TouchpadScroll> {
- if {[expr {%# %% 15}] != 0} {
+ if {%# %% 5 != 0} {
return
}
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY