Tk Source Code

View Ticket
Login
Ticket UUID: 1927212
Title: MouseWheel unbound for non-aqua scrollbars
Type: Patch Version: 8.5
Submitter: matben Created on: 2008-03-27 15:31:53
Subsystem: 16. [scrollbar] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2018-09-23 20:10:10
Resolution: Fixed Closed By: fvogel
    Closed on: 2018-09-23 20:10:10
Description:
The scrollbar should bind to MousWheel on non aqua platforms too:
if {[tk windowingsystem] eq "aqua"} {
    bind Scrollbar <MouseWheel> {
        tk::ScrollByUnits %W v [expr {- (%D)}]
    }
    bind Scrollbar <Option-MouseWheel> {
        tk::ScrollByUnits %W v [expr {-10 * (%D)}]
    }
    bind Scrollbar <Shift-MouseWheel> {
        tk::ScrollByUnits %W h [expr {- (%D)}]
    }
    bind Scrollbar <Shift-Option-MouseWheel> {
        tk::ScrollByUnits %W h [expr {-10 * (%D)}]
    }
}

but the bindings look a bit different, see MouseWheel in library/text.tcl
User Comments: fvogel added on 2018-09-23 20:10:10:

Tweaking of the scrollbar-10.1|2 tests so that they pass for all platforms including macOS later happened in [874dca4873].


jan.nijtmans added on 2016-01-09 22:32:10:
Fix and test-case merged to trunk and core-8-5-branch. Thanks!

fvogel added on 2016-01-09 00:09:08:
Fixed test cases, they pass now.

Regarding -constraints {win|unix}: I have added this because the tests results will not be the same for Mac (I think).

fvogel added on 2016-01-08 20:56:08:
Now that I see the 8.6 code I'm wondering whether the "x11" case should be the same as the "win32" case. Currently, in the "win32" case four units are scrolled for each <MouseWheel> event, but only one unit is scrolled in the "x11" case. Why this difference? Both platforms generate %D == +/-120 for one <MouseWheel>.

jan.nijtmans added on 2016-01-08 15:43:04:

New fix-attempt in [972d3670cd101e97] (for both horizontal and vertical scrollbars)


jan.nijtmans added on 2016-01-08 14:50:43:
Patch reverted, as it produces a lot of test-failures on Linux (Ubuntu).... Investigating, probably was too quick ....

fvogel added on 2016-01-08 14:30:57:
Merged (by Jan Nijtmans) to trunk, and cherrypicked to core-8-5-branch.

fvogel added on 2016-01-06 16:00:41:
Patch proposed in branch bug-1927212fff

fvogel added on 2016-01-02 13:56:04:
Are you suggesting to just propagate (in the non-aqua case) to the scrollbar the <MouseWheel> bindings from text.tcl?

I.e. are you suggesting to apply the following patch:

--- library/scrlbar.tcl
+++ library/scrlbar.tcl
@@ -139,11 +139,26 @@
         tk::ScrollByUnits %W h [expr {- (%D)}]
     }
     bind Scrollbar <Shift-Option-MouseWheel> {
         tk::ScrollByUnits %W h [expr {-10 * (%D)}]
     }
+} else {
+    # We must make sure that positive and negative movements are rounded
+    # equally to integers, avoiding the problem that
+    #     (int)1/3 = 0,
+    # but
+    #     (int)-1/3 = -1
+    # The following code ensure equal +/- behaviour.
+    bind Scrollbar <MouseWheel> {
+    if {%D >= 0} {
+        tk::ScrollByUnits %W v [expr {-%D/3}]
+      } else {
+        tk::ScrollByUnits %W v [expr {(2-%D)/3}]
+      }
+    }
 }
+
 # tk::ScrollButtonDown --
 # This procedure is invoked when a button is pressed in a scrollbar.
 # It changes the way the scrollbar is displayed and takes actions
 # depending on where the mouse is.
 #

That would make the <MouseWheel> event scroll *40* units for each triggered event. For instance when the scrollbar is used for vertical scrolling in a text widget, each <MouseWheel> event would scroll 40 lines. Looks definitely too much for me. 

I think each <MouseWheel> should scroll exactly one unit, this is precisely the usefulness of "units" (see the scrollbar man page). Therefore I would rather apply the following patch:

--- library/scrlbar.tcl
+++ library/scrlbar.tcl
@@ -139,11 +139,16 @@
         tk::ScrollByUnits %W h [expr {- (%D)}]
     }
     bind Scrollbar <Shift-Option-MouseWheel> {
         tk::ScrollByUnits %W h [expr {-10 * (%D)}]
     }
+} else {
+    bind Scrollbar <MouseWheel> {
+        tk::ScrollByUnits %W v [expr {- (%D/120)}]
+    }
 }
+
 # tk::ScrollButtonDown --
 # This procedure is invoked when a button is pressed in a scrollbar.
 # It changes the way the scrollbar is displayed and takes actions
 # depending on where the mouse is.
 #


Other opinions?