summaryrefslogtreecommitdiffstats
path: root/library/demos
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2023-11-24 20:32:20 (GMT)
committermarc_culler <marc.culler@gmail.com>2023-11-24 20:32:20 (GMT)
commit1e3a4e7a0607ab4e6f8af6717eed1792fd38fab3 (patch)
treed010f9801b080ab5f776e06f3fb7e7706347fc46 /library/demos
parent882e2f294e951a18ea24b7a5f1d6628bc5a4ae90 (diff)
downloadtk-1e3a4e7a0607ab4e6f8af6717eed1792fd38fab3.zip
tk-1e3a4e7a0607ab4e6f8af6717eed1792fd38fab3.tar.gz
tk-1e3a4e7a0607ab4e6f8af6717eed1792fd38fab3.tar.bz2
Add touchpad bindings to the canvas items demo.
Diffstat (limited to 'library/demos')
-rw-r--r--library/demos/items.tcl8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/demos/items.tcl b/library/demos/items.tcl
index 5f51a90..bdd2cc2 100644
--- a/library/demos/items.tcl
+++ b/library/demos/items.tcl
@@ -34,6 +34,14 @@ canvas $c -scrollregion {0c 0c 30c 24c} -width 15c -height 10c \
ttk::scrollbar $w.frame.vscroll -command "$c yview"
ttk::scrollbar $w.frame.hscroll -orient horizontal -command "$c xview"
+#Touchpad scrolling
+bind $c <Control-MouseWheel> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ if {$deltaX != 0 || $deltaY != 0} {
+ tk::CanvasScrollByPixels %W $deltaX $deltaY
+ }
+}
+
grid $c -in $w.frame \
-row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
grid $w.frame.vscroll \