Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Perl Tk Scrolled widget callbacks

by thundergnat (Deacon)
on Mar 01, 2013 at 16:56 UTC ( #1021298=note: print w/replies, xml ) Need Help??

in reply to Perl Tk Scrolled widget callbacks

It should be possible to hook into the <<MenuSelect>> virtual event bound to the popup menu but I am having a hard time figuring out how to do so...

Another less elegant way is to just poll the state of the -wrap option and do your callback when it changes.

use warnings; use strict; use Tk; my $mw = new MainWindow; $mw->geometry("200x200"); my $frame = $mw->Frame()->pack; my $textbox = $frame->Scrolled('Text', -scrollbars => 'soe', -foreground => 'blue', -background => 'white', -wrap => 'none', )->pack; $textbox->insert('end', "This is scrolled widget.\nThis is scrolled wi +dget.This is scrolled widget"); my $wrapmonitor = $textbox->cget('wrap'); $textbox->repeat(100, sub { if ( $textbox->cget('wrap') ne $wrapmonitor ){ $wrapmonitor = $textbox->cget('wrap'); mycallback($wrapmonitor) #whatever } } ); MainLoop; sub mycallback { print shift, "\n"; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-03-20 23:52 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (262 votes). Check out past polls.