Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have another Mousewheel question related to Tk::BrowseEntry.
On Linux when the pop-up listbox has a scrollbar, I can use the mousewheel to scroll the listbox without having to define any new bindings.
On Windows (Strawberry Perl) this does not work. The mousewheel does nothing.

So I have been trying to set up the binding myself but despite trying various subwidget targets (all those commented out in the example below) I haven't managed to get the mousewheel to scroll the listbox on Windows.

Does anybody know what the correct binding for this is?

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::BrowseEntry; my $mw=tkinit(); my $var='opt2'; my $b=$mw->BrowseEntry(-label => "Choose:", -variable => \$var, -style => 'MSWin32', -listheight => 5, -browsecmd => sub{ print STDOUT $var."\n" } ); $b->insert("end", "opt1"); $b->insert("end", "opt2"); $b->insert("end", "opt3"); $b->insert("end", "opt4"); $b->insert("end", "opt5"); $b->insert("end", "opt6"); $b->insert("end", "opt7"); $b->insert("end", "opt8"); $b->insert("end", "opt9"); $b->insert("end", "optA"); $b->insert("end", "optB"); $b->insert("end", "optC"); #my $lbx=$b->Subwidget("slistbox")->Subwidget("yscrollbar"); #my $lbx=$b->Subwidget("slistbox")->Subwidget("scrolled"); #my $lbx=$b->Subwidget("slistbox")->Subwidget("listbox"); #my $lbx=$b->Subwidget("choices"); my $lbx=$b->Subwidget("slistbox"); $lbx->bind('<MouseWheel>',[sub{$_[0]->yview('scroll',-($_[1]/120)*3,'u +nits')}, Ev("D")]); $b->pack; MainLoop;

In reply to Tk::BrowseEntry listbox scrollbar with Mousewheel on Windows by perltux

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 avoiding work at the Monastery: (6)
As of 2024-05-30 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found