Elijah has asked for the wisdom of the Perl Monks concerning the following question:

I need some help figuring out what represents the scroll wheel so I can bind it to some specific actions in my program.

I have tried binding <3>, <4> and <5> but nothing.

$t->bind('Tk::Text', '<4>', sub {print "Scroll up!"}); $t->bind('Tk::Text', '<5>', sub {print "Scroll down!"});

This is the code I used to create the binding. Any help?

Replies are listed 'Best First'.
Re: Ideas on binding scrollwheel?
by PodMaster (Abbot) on Jan 08, 2004 at 23:20 UTC
    Why did you try 3,4,5 (the Tk::Text docs say nothing about the mouswheel)? Try <MouseWheel>

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      3,4 and 5 are are the XWindows button's that are triggered when you use the wheel. 4 and 5 are up and down (in some order). Anyway, it's the native X mouse buttons. It doesn't mean that API's represent it as such, as you have shown. In the C one it should, but I haven't written for the mouse wheel :)

      Under the hood of Tk, it gets mouse button "signals" 3,4,5 and the internals of Tk will create events in turn that you receieve when you write event listeners.


      Play that funky music white boy..
      Actually <MouseWheel> did work on my Win XP system. I was a little relunctant to try it due to what the author said but mine worked fine.