Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found