Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Perl/Tkx Mousewheel

by jethro (Monsignor)
on Mar 10, 2009 at 16:07 UTC ( #749636=note: print w/replies, xml ) Need Help??

in reply to Perl/Tkx Mousewheel

You might use Data::Dumper to show you the contents of the array you are getting, i.e.

use Data::Dumper; ... $canvas->g_bind("<MouseWheel>", sub { Dumper( Tkx::Ev('%D')) . "\n";

Presumably the information you are looking for is in that array, just an indirection away

UPDATE: Tkx::Ev seems to return an object!!! Accessing the array would be a hack, maybe you can find the right accessor in the documentation.

Replies are listed 'Best First'.
Re^2: Perl/Tkx Mousewheel
by chiron (Novice) on Mar 10, 2009 at 17:08 UTC
    I've worked out a solution to this problem, however I'm still slightly unsure of whats going on here. Thanks for your help.
    $canvas->g_bind("<MouseWheel>", [ sub { my($D) = @_; print $D . "\n"; +}, Tkx::Ev("%D") ]);

      This seems to be a special two-parameter form for the binding (it uses an anonymous array), where the first parameter (or array value) is the sub as before, and the second furnishes the parameters for the sub. Tkx::Ev just does that. See for this explanation:

      Tkx lets us provide command callbacks as just a Perl function (the first four), or as a two element array (the last case). The first element is the Perl code to be called, while the second array element specifies parameters to pass to that code. The function "Tkx::Ev()" will expand its parameter ("%x %y" in this case) when the callback is invoked, which will perform the percent substitutions. These then are passed as parameters to our function.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://749636]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2023-03-20 09:45 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.