Re: Can not intercept and disable MouseWheel on a canvas



Mumia W. wrote:
On 04/21/2010 04:59 PM, Lamprecht wrote:
Mumia W. wrote:

None of these methods, and a dozen others I tried, work to disable
mouse-wheel scrolling for canvas widgets. How do I do this? I'm using
Debian 5.0, Perl 5.10.0 and Perl-tk 804.028.


Hi Mumia,

check <Button-4> and <Button-5> event handlers,
(<MouseWheel> is a Windows thing).

Christoph


Thanks, that sort of works. I can intercept mouse wheel events, but I still can't disable the scrolling. I tried this:

$canvas->CanvasBind('<Button-4>', '');
$canvas->CanvasBind('<Button-5>', '');

However, I still get scrolling. Can I disable that?


It seems to be the Window manager, that does this.

You can force an yview reset:

$canvas->CanvasBind("<$_>", sub {
$canvas->yviewMoveto( 0 )})for (4,5);

Or set up a negative scollbinding (possibly needs adjustment of the number):
$canvas->CanvasBind("<4>", sub {
$canvas->yviewScroll( 1,'units' )});
$canvas->CanvasBind("<5>", sub {
$canvas->yviewScroll( -1,'units' )});


Cheers, Christoph

--
Tk::EntrySet
display/edit a list of values in a Set of Widgets.
Tk::ChoicesSet
display/edit a list of choices in a Set of single-selection Widgets.
.



Relevant Pages