summaryrefslogtreecommitdiffstats
path: root/library/iconlist.tcl
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-08-16 14:51:22 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-08-16 14:51:22 (GMT)
commit64be854d97cacfa743144a08a60b4ea3b74b484a (patch)
treef270f41b6867df85fc605debdef26195edff24ae /library/iconlist.tcl
parent4875d4135079ccec5bf1e4e60a5b6a835dbc8602 (diff)
downloadtk-64be854d97cacfa743144a08a60b4ea3b74b484a.zip
tk-64be854d97cacfa743144a08a60b4ea3b74b484a.tar.gz
tk-64be854d97cacfa743144a08a60b4ea3b74b484a.tar.bz2
Refactor all MouseWheel bindings, doing it the same way everywhere. So <MouseWheel> bindings are there on all platforms, (Button-4|5) only on X11.
Also add bindings for vertical scrolling for iconlist, as suggested by Max Augsburg. (still to be tested on X11 and MacOS)
Diffstat (limited to 'library/iconlist.tcl')
-rw-r--r--library/iconlist.tcl21
1 files changed, 21 insertions, 0 deletions
diff --git a/library/iconlist.tcl b/library/iconlist.tcl
index 62b0b2d..521ec37 100644
--- a/library/iconlist.tcl
+++ b/library/iconlist.tcl
@@ -446,6 +446,17 @@ package require Tk 8.6
bind $canvas <Control-B1-Motion> {;}
bind $canvas <Shift-B1-Motion> [namespace code {my ShiftMotion1 %x %y}]
+ if {[tk windowingsystem] eq "aqua"} {
+ bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel [expr {40 * (%W)}]}]
+ bind $canvas <Option-Shift-MouseWheel> [namespace code {my MouseWheel [expr {400 * (%W)}]}]
+ } else {
+ bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel %W}]
+ }
+ if {[tk windowingsystem] eq "x11"} {
+ bind $canvas <Shift-4> [namespace code {my MouseWheel 120}]
+ bind $canvas <Shift-5> [namespace code {my MouseWheel -120}]
+ }
+
bind $canvas <<PrevLine>> [namespace code {my UpDown -1}]
bind $canvas <<NextLine>> [namespace code {my UpDown 1}]
bind $canvas <<PrevChar>> [namespace code {my LeftRight -1}]
@@ -492,6 +503,16 @@ package require Tk 8.6
# ----------------------------------------------------------------------
# Event handlers
+ method MouseWheel {amount} {
+ if {$noScroll || $::tk_strictMotif} {
+ return
+ }
+ if {$amount > 0} {
+ $canvas xview scroll [expr {(-119-$amount) / 120}] units
+ } else {
+ $canvas xview scroll [expr {-($amount / 120)}] units
+ }
+ }
method Btn1 {x y} {
focus $canvas
set i [$w index @$x,$y]