I would like to use my mouse wheel in a perl Tk program I have. It is used on a Windows 7 machine running Perl 5.8.8. I can get the program to recognize that a wheel event has occurred; I just can't differentiate between scrolling the wheel up and scrolling the wheel down.

The following is a small snippet demonstrating the problem.

use strict; use Tk; my $mw = MainWindow->new(); $mw->bind('<MouseWheel>'=>sub{print 'wheel moved';}); MainLoop;

The above prints 'wheel moved' regardless whether I scroll it up or down. I have looked up everything I can find and can not figure out in Windows how to distinguish the up from down. I have re-read page 370-371 in 'Mastering Perl/Tk' several times.

There are sample listings that use $_[0]->yview('scroll', but that doesn't appear to work on my machine, and I am not scrolling but calling other routines depending on the direction. I don't appear to get anything in $_[1] at all that they refer to. I have looked all over in the $_[0] and not found the answer.

I can't add any CPAN modules to solve this. I am guessing there must be some simple variable that returns the up or down-ness of the wheel movement.


In reply to Wheel stuck in rut by ExReg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.