Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Perl Tk Scrolled widget callbacks

by thundergnat (Deacon)
on Mar 01, 2013 at 16:56 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1021298]
help
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-04-19 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found