summaryrefslogtreecommitdiffstats
path: root/library/demos
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2023-11-19 14:21:41 (GMT)
committermarc_culler <marc.culler@gmail.com>2023-11-19 14:21:41 (GMT)
commit295a4dd3fc0ace2082cfc84d80601b6efb7c56c8 (patch)
treefd99be35a05c481d3c3df87a6cb28527f044d1dc /library/demos
parent6985b2c91a0a68e768f0c27a7e21e38fcb657fba (diff)
downloadtk-295a4dd3fc0ace2082cfc84d80601b6efb7c56c8.zip
tk-295a4dd3fc0ace2082cfc84d80601b6efb7c56c8.tar.gz
tk-295a4dd3fc0ace2082cfc84d80601b6efb7c56c8.tar.bz2
Fix Scrollbar bindings
Diffstat (limited to 'library/demos')
-rw-r--r--library/demos/cscroll.tcl19
1 files changed, 19 insertions, 0 deletions
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl
index 41f6d5d..54d98e0 100644
--- a/library/demos/cscroll.tcl
+++ b/library/demos/cscroll.tcl
@@ -27,6 +27,25 @@ pack $btns -side bottom -fill x
frame $w.grid
ttk::scrollbar $w.hscroll -orient horizontal -command "$c xview"
ttk::scrollbar $w.vscroll -command "$c yview"
+# Override the scrollbar's mousewheel binding to speed it up:
+set fastwheel {
+ set HiresScrollMask 512
+ set ShiftMask 1
+ if {[expr {%s & $ShiftMask}]} {
+ set orientation "h";
+ } else {
+ set orientation "v";
+ }
+ if {[expr {%s & $HiresScrollMask}]} {
+ tk::ScrollByUnits %W $orientation %D -1.0
+ } else {
+ tk::ScrollByUnits %W $orientation %D -30.0
+ }
+ break
+}
+bind $w.vscroll <MouseWheel> $fastwheel
+bind $w.hscroll <MouseWheel> $fastwheel
+
canvas $c -relief sunken -borderwidth 2 -scrollregion {-11c -11c 50c 20c} \
-xscrollcommand "$w.hscroll set" \
-yscrollcommand "$w.vscroll set"