diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-01-09 22:16:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-01-09 22:16:59 (GMT) |
commit | 2522c0935ba3317f2f6a19894ec0ae5fff3fcc95 (patch) | |
tree | 54cc3d2a92b107d7fa356fd29d4a9f981e12df0e | |
parent | 6bf6ee6b7d3a18018a983b58f8067553198ca090 (diff) | |
parent | 631b7815fb57704361344f53cad675ffdbbd6d13 (diff) | |
download | tk-2522c0935ba3317f2f6a19894ec0ae5fff3fcc95.zip tk-2522c0935ba3317f2f6a19894ec0ae5fff3fcc95.tar.gz tk-2522c0935ba3317f2f6a19894ec0ae5fff3fcc95.tar.bz2 |
Fix [1927212]: MouseWheel unbound for non-aqua scrollbars. Thanks to Francois Vogel for the actual work
-rw-r--r-- | library/scrlbar.tcl | 6 | ||||
-rw-r--r-- | tests/scrollbar.test | 30 |
2 files changed, 36 insertions, 0 deletions
diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index e17442f..b7be014 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -152,6 +152,12 @@ switch [tk windowingsystem] { } } "x11" { + bind Scrollbar <MouseWheel> { + tk::ScrollByUnits %W v [expr {- (%D /120 ) * 4}] + } + bind Scrollbar <Shift-MouseWheel> { + tk::ScrollByUnits %W h [expr {- (%D /120 ) * 4}] + } bind Scrollbar <4> {tk::ScrollByUnits %W v -5} bind Scrollbar <5> {tk::ScrollByUnits %W v 5} bind Scrollbar <Shift-4> {tk::ScrollByUnits %W h -5} diff --git a/tests/scrollbar.test b/tests/scrollbar.test index c6a5a90..3b16821 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -632,6 +632,36 @@ test scrollbar-9.1 {scrollbar widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] +test scrollbar-10.1 {<MouseWheel> event on scrollbar} -constraints {win|unix} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s <MouseWheel> -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} + +test scrollbar-10.2 {<MouseWheel> event on scrollbar} -constraints {win|unix} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s <Shift-MouseWheel> -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} + catch {destroy .s} catch {destroy .t} |