Subject: (cherry-pick) Fix [1927212]: MouseWheel unbound for non-aqua scrollbars. Thanks to Francois Vogel for the actual work

From: "jan.nijtmans" <[email-masked]>
Date: Sat, 9 Jan 2016 22:30:01 +0000

---
 library/scrlbar.tcl  |  7 +++++++
 tests/scrollbar.test | 30 ++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl
index 4b25325..43ce4ae 100644
--- a/library/scrlbar.tcl
+++ b/library/scrlbar.tcl
@@ -141,6 +141,13 @@ if {[tk windowingsystem] eq "aqua"} {
     bind Scrollbar <Shift-Option-MouseWheel> {
         tk::ScrollByUnits %W h [expr {-10 * (%D)}]
     }
+} else {
+    bind Scrollbar <MouseWheel> {
+	tk::ScrollByUnits %W v [expr {- (%D /120 ) * 4}]
+    }
+    bind Scrollbar <Shift-MouseWheel> {
+	tk::ScrollByUnits %W h [expr {- (%D /120 ) * 4}]
+    }
 }
 # tk::ScrollButtonDown --
 # This procedure is invoked when a button is pressed in a scrollbar.
diff --git a/tests/scrollbar.test b/tests/scrollbar.test
index 5d4334f..35f48bd 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}
 
-- 
cgit v0.12