summaryrefslogtreecommitdiffstats
path: root/library/tk.tcl
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2023-11-28 03:38:54 (GMT)
committermarc_culler <marc.culler@gmail.com>2023-11-28 03:38:54 (GMT)
commit9c14936e2980f87eafc2b80694de4f73abf9ebc0 (patch)
tree3c86d0317e944738dd8ced84210c185df01501eb /library/tk.tcl
parent1b1276420e9016d6eddf1cfc49642a0ffcf3535f (diff)
downloadtk-9c14936e2980f87eafc2b80694de4f73abf9ebc0.zip
tk-9c14936e2980f87eafc2b80694de4f73abf9ebc0.tar.gz
tk-9c14936e2980f87eafc2b80694de4f73abf9ebc0.tar.bz2
Add bindings for listbox and treeview. Some code clean up.
Diffstat (limited to 'library/tk.tcl')
-rw-r--r--library/tk.tcl18
1 files changed, 10 insertions, 8 deletions
diff --git a/library/tk.tcl b/library/tk.tcl
index 1345fbf..656ad00 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -845,16 +845,18 @@ if {$::ttk::library ne ""} {
uplevel \#0 [list source -encoding utf-8 $::ttk::library/ttk.tcl]
}
-# Helper for smooth scrolling of Canvas widgets
-proc ::tk::CanvasScrollByPixels {canvas deltaX deltaY} {
- set width [expr {1.0 * [$canvas cget -width]}]
- set height [expr {1.0 * [$canvas cget -height]}]
- set X [lindex [$canvas xview] 0]
- set Y [lindex [$canvas yview] 0]
+# 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}]
- $canvas xview moveto $x
- $canvas yview moveto $y
+ $w xview moveto $x
+ $w yview moveto $y
}