Skip Menu |

This queue is for tickets about the Tcl-pTk CPAN distribution.

Report information
The Basics
Id: 125048
Status: resolved
Priority: 0/
Queue: Tcl-pTk

People
Owner: CAC [...] cpan.org
Requestors: CAC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.92
Fixed in: 0.93



Subject: [macOS] mousewheel issue for Scrolled
(I'm in the process of getting an existing Perl/Tk program working with TkHijack, cf. https://github.com/hotwolf/HSW12/issues/16. I'm particularly interested in getting it to work for macOS, since TkHijack lets programs run without XQuartz. For any issues I encounter, I will see if they can be reproduced using the modified widget demo in Tcl::pTk, and can open additional tickets if appropriate. I'm still relatively new to Perl and Tk, but I'm willing to do any testing and possibly investigate/contribute fixes for relevant Tcl::pTk issues.) Scrolling using the mouse wheel for Scrolled widgets works only when the mouse pointer is directly over the scrollbar/trough; i.e. having the mouse pointer directly over the text area does not allow scrolling with the mouse wheel. This only seems to happen on macOS, and not on e.g. Windows or Linux. This can be reproduced in the widget demo, either from the MainWindow or any of the examples using Scrolled.
This issue is because the scaling of the MouseWheel units is too small. See http://wiki.tcl.tk/3893 Show quoted text
> Kevin Walzer: On OS X/Aqua the correct mousewheel binding would be:
>> bind .t.c <MouseWheel> {%W yview scroll [expr {- (%D)}] units}
I have adapted this scaling behavior for Tcl::pTk::Widget::MouseWheelBind, and vertical scrolling now works; see attached patch. It would be nice if horizontal scrolling worked, though that is missing from other platforms as well.
Subject: macos-scrollwheel.patch
Index: lib/Tcl/pTk/Widget.pm =================================================================== --- lib/Tcl/pTk/Widget.pm (revision 198) +++ lib/Tcl/pTk/Widget.pm (working copy) @@ -2415,16 +2415,18 @@ # The MouseWheel will typically only fire on Windows. However, one # could use the "event generate" command to produce MouseWheel # events on other platforms. $mw->bind($class, '<MouseWheel>', - [ sub { $_[0]->yview('scroll',-int(($_[1]/120)),'units') }, Tcl::pTk::Ev("D")]); + $mw->windowingsystem eq 'aqua' + ? [ sub { $_[0]->yview('scroll',-($_[1]),'units'); print $_[2]; }, Tcl::pTk::Ev("D")] + : [ sub { $_[0]->yview('scroll',-int(($_[1]/120)),'units') }, Tcl::pTk::Ev("D")]);
I didn't mean the leave the print $_[2] statement in the patch, it is unnecessary.

I've also opened a pull request with Perl/Tk for the same change, in case it gets aqua working one day. https://github.com/eserte/perl-tk/pull/35