Hmm, validating only makes sense for single-line widgets ... anywho
#!/usr/bin/perl --
use Tk;
use strict;
use warnings;
Main(@ARGV);
exit(0);
sub Main {
our $status = "";
my $mw = tkinit;
my $t = $mw->Scrolled(qw/
Text
-relief sunken
-borderwidth 2
-setgrid true
-height 30
-scrollbars e
/)->pack(qw/
-expand yes
-fill both
/);
my $l = $mw->Label(
-textvariable => \$status,
-relief => 'groove',
-font => "Arial",
-anchor => 'center',
)->pack(
-side => 'bottom',
-anchor => 's',
-fill => 'both',
);
use DDS; Dump( $l );
$t->bind( '<<Modified>>' => [ \&onModified , $t , $l ]);
MainLoop;
}
sub onModified {
## warn " @_ "; ## go-figure , probably a bug
## Tk::Text=HASH(0xeb324c) Tk::Frame=HASH(0xed2fcc) Tk::Label=HASH(0x
+fbfb94)
my( $t, undef, $l ) = @_;
if( $t->editModified ){
$t->editModified(0); ## reset count
if( "invalid" ){
$t->bell;
$::status = "invalid, forever";
$l->configure ( -background => 'red' );
}
}
return;
}
widget