Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

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


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

Hi,

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found