Hi, I'm trying to get MouseWheel support for the TK::Scale widget in Windows working but I don't really understand how. The few examples I've found on the Net refer to other widgets and don't seem to work for me when trying to apply them to a Scale widget.
Here is my test code (mouse wheel is not working with this code on Windows):
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $var=0;
my $incr=1;
my $mw=MainWindow->new();
my $scale=$mw->Scale(
-variable => \$var,
-to => -63,
-from => 63,
-resolution => $incr,
-tickinterval => 0,
-label => '',
-width => 10,
-length => 150,
-sliderlength => 20,
-borderwidth => 1,
-highlightthickness => 0,
-showvalue => 1,
-orient => 'vertical'
)->pack(-padx=>50);
# Linux/Unix mouse wheel binding
$scale->bind('<Button-4>' => sub{$scale->set($var+$incr)});
$scale->bind('<Button-5>' => sub{$scale->set($var-$incr)});
# Windows mouse wheel binding (not working)
$scale->bind('<MouseWheel>' => [ sub { $_[0]->set($var+$incr*($_[1] /
+120))}, Ev('D') ] );
MainLoop;
How do I get this working on Windows? (on Linux it works fine, the binding is sooo much easier)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.