Tk Source Code

View Ticket
Login
Ticket UUID: 7f1aa9b83b06167c3cd7662dc38aa87f01938b6d
Title: On Windows mousewheel events are not sensitive to shift and control modifiers
Type: Bug Version: 8.6.6
Submitter: anonymous Created on: 2017-05-30 08:12:11
Subsystem: 01. Bindings Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2017-08-11 07:53:17
Resolution: Invalid Closed By: fvogel
    Closed on: 2017-08-11 07:53:17
Description:
In the module controlwidget (Tklib) Gerhard Reithofer has recently added suppport for mousewheel events. This has to be done differently for Linux and Windows.

While for Linux the shift and control buttons (modifiers) can be used to modify the stepsize (interpretation of the events), this does not happen for Windows. It appears the modifiers are not honoured.
User Comments: arjenmarkus added on 2017-08-11 06:55:06:
Right, that seems a useful workaround/solution. The interpretation of the modifiers is up to the application, I'd say, unless there are strong (platform-specific) guidelines. 

The important part is that the information is actually available.

fvogel added on 2017-06-30 19:47:46:

Oh, and using the %s substitution you can know whether a modifier was pressed or not, so that you can do something like:

package require Tk
pack [text .t]
bind .t <MouseWheel> {
    set stepsize %D
    if {%s ==  9} {set stepsize [expr {%D*2}]}
    if {%s == 12} {set stepsize [expr {%D*5}]}
    puts "%%D: %D    state:%s    stepsize:$stepsize\n"
}

(and this is platform-independent).


fvogel added on 2017-06-30 19:40:52:

Not sure I understand what you mean. Are you saying that holding the shift or control key down during mouse wheel rotation should change the %D value?

Example script:

  package require Tk
  pack [text .t]
  bind .t <MouseWheel> {puts "Delta: %D    state:%s\n"}
  bind .t <Shift-MouseWheel> {puts "Delta: %D    state:%s\n"}
  bind .t <Control-MouseWheel> {puts "Delta: %D    state:%s\n"}

For me, on Windows, when using the mouse wheel with or without a modifier, the value of %D is always +/-120, which is what is expected I think.

I thought that the modifier keys were rather used to change the direction of the scrolling, i.e. <Mousewheel> scrolls vertically, and <Shift-MouseWheel> scrolls horizontally. Such use can be found in the current Tk codee base.