Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: perl/Tk Entry validation

by choroba (Cardinal)
on Jul 24, 2012 at 10:12 UTC ( [id://983351]=note: print w/replies, xml ) Need Help??


in reply to perl/Tk Entry validation

For some reason I cannot see at the moment, validation is turned off (probably related to this part of the documentation:
The validateCommand will turn itself off by setting validate to none when an error occurs, for example when the validateCommand or invalidCommand encounters an error in its script while evaluating, or validateCommand does not return a valid boolean value.
). An easy workaround is to reset the -validate in the invalidcommand:
#!/usr/bin/perl use warnings; use strict; use Tk; my $embCanvas = MainWindow->new; my $xVConsSflEmbMax0 = 1; my $xVConsSflEmbMax = $xVConsSflEmbMax0; my $emb1Entry = $embCanvas->Entry( -textvariable => \$xVConsSflEmbMax, -width => 3, -validate => 'focusout', -validatecommand => sub { warn "@_\n"; $_[0] =~ /^\d*\.?\d+$/ } +, -invalidcommand => \&invalid, )->pack; my $qb = $embCanvas->Button( -text => 'Quit', -command => sub { exit } )->pack; MainLoop(); sub invalid { $xVConsSflEmbMax = $xVConsSflEmbMax0; $emb1Entry->configure(-validate => 'focusout'); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-24 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found