Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: How do I bind the Mousewheel to Tk::BrowseEntry?

by beech (Vicar)
on Apr 01, 2017 at 08:58 UTC ( #1186662=note: print w/replies, xml ) Need Help??

in reply to How do I bind the Mousewheel to Tk::BrowseEntry?


This seems to work, UTSL saves the day

#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::BrowseEntry; { my $mw = tkinit(); my $var = 'initial label'; my $b = $mw->BrowseEntry(-label => "Label", -variable => \$var); $b->insert("end", "opt1"); $b->insert("end", "opt2"); $b->insert("end", "opt3"); $b->pack; WheelsUp($b ); $mw->focusFollowsMouse; MainLoop; } sub WheelsUp { my( $b ) = @_; my $mw = $b->toplevel; for my $wi ( $b, map { $_, $_->children } $b->children ){ $mw->bind( $wi, '<MouseWheel>',[ \&wheel_browse, $b, Tk::Ev('D +')]); $mw->bind( $wi, '<4>',[ \&wheel_browse , $b, 120]); $mw->bind( $wi, '<5>',[ \&wheel_browse , $b, -120]); $mw->bind( $wi, '<Up>',[ \&wheel_browse , $b, 1]); $mw->bind( $wi, '<Down>',[ \&wheel_browse , $b, -1]); } } sub wheel_browse { my( $main, $bro, $num ) = @_; my $lb = $bro->Subwidget("slistbox")->Subwidget('listbox'); $num = $num < 0 ? -1 : 1; $lb->UpDown( $num ); my $var_ref = $bro->cget( '-textvariable' ); $$var_ref = $lb->getSelected; return; } __END__

Replies are listed 'Best First'.
Re^2: How do I bind the Mousewheel to Tk::BrowseEntry?
by perltux (Monk) on Apr 01, 2017 at 12:46 UTC
    Yes, it does work indeed, thank you very much!!

    I had spent hours on this previously getting nowhere, you clearly are a Perl genius!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1186662]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-07-16 22:46 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (352 votes). Check out past polls.