Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Onchange-like event handler for Tk text widget

by lamprecht (Friar)
on Apr 11, 2011 at 22:52 UTC ( [id://898799]=note: print w/replies, xml ) Need Help??


in reply to Onchange-like event handler for Tk text widget

Update: Please ignore - <<Modified>> works as advertised...

There seems to be a bug on Win32 which keeps <<Modified>> from being generated in case of a Ctrl-V paste. Here is another way to trigger on modifications:

use warnings; use strict; use Tk; my $mw = tkinit; $mw->Text; my $insert = \&Tk::Text::insert; *Tk::Text::insert = sub{changed($_[0]); $insert->(@_); }; my $t = $mw->Text->pack; #$t->bind('<<Modified>>',sub{print shift," changed\n"}); MainLoop; sub changed{ print "$_[0] changed\n"; }
Cheers, Christoph

Replies are listed 'Best First'.
Re^2: Onchange-like event handler for Tk text widget
by vkon (Curate) on Apr 12, 2011 at 07:29 UTC
    I do not know what bug you're talking about,
    my code, rewritten adopted to Tk, behaves correctly for win32, including ctrl+v copy-pasting:
    use Tk; my $t=tkinit->Text->pack; $t->bind('<<Modified>>'=>sub { if($t->editModified) {print qq/chg\n/;$t->editModified(0)} }); MainLoop;

      You are right. I possibly did something stupid like trying to paste from an empty clipboard. Thanks for the clarification.

      Cheers, Christoph
      Dear Monks, thanks a lot. I'll try that. Greetings Lodae

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2026-04-11 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.