Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Using Tk::Text and '<<Modified>>'

by rrwo (Friar)
on Nov 20, 2004 at 13:18 UTC ( [id://409255]=note: print w/replies, xml ) Need Help??


in reply to Using Tk::Text and '<<Modified>>'

If you want your routine to be called with every keystroke, then bind every keystroke.

Your callback was called once when it was modified. Since you now know it's been modified, there's no reason to call it again.

I don't have the Tk docs with me here, but I recall that you have to reset some kind of flag when modified has been called.

Replies are listed 'Best First'.
Re^2: Using Tk::Text and '<<Modified>>'
by pg (Canon) on Nov 20, 2004 at 17:48 UTC
    "If you want your routine to be called with every keystroke, then bind every keystroke."

    That was my first thought too, but that does not seem to work either.

    use warnings; use strict; use Tk; my $MW = MainWindow->new(-title => "Tk::Text test", -width => 200, -height => 200); my $text = $MW->Text(-height => 10, -width => 40, -wrap => 'word'); $text->pack(-side => 'top', -fill => 'both'); $text->bind('<<Modified>>' => sub { getText($text, @_) } ); MainLoop; sub getText { my ($t, @args) = @_; my $str = $t->get('0.0', 'end'); print "Got: $str\n"; $text->bind('<<Modified>>' => sub { getText($str, @_) } ); return if(!$str); return 1; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2025-01-23 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (66 votes). Check out past polls.