Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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"; }


Comment on Re: Perl Tk Scrolled widget callbacks
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-10-23 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (129 votes), past polls