in reply to Re: Perl Tk entry widget
in thread Perl Tk entry widget

Hello Ken,

The -validatecommand does not work if manually some text is written to the entry widget

Replies are listed 'Best First'.
Re^3: Perl Tk entry widget
by beech (Parson) on Feb 25, 2016 at 23:32 UTC

    The -validatecommand does not work if manually some text is written to the entry widget

    See https://metacpan.org/pod/Tk::Entry#VALIDATION, by default no validation is performed

    #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ pp /; use Tk; my $mw = tkinit; $mw->Entry( -validate => 'all', -validatecommand => sub { warn pp(\@_); return 1 if !length$_[0] or $_[0] =~ m{^\d+$}; return undef; }, )->pack; $mw->MainLoop;
Re^3: Perl Tk entry widget
by kcott (Archbishop) on Feb 26, 2016 at 04:17 UTC

    Having spent a fair amount of time digging up all the relevant sections in Tk::Entry, so that you didn't have to read the entire documentation, I'm less than impressed that you chose to respond with nothing more than:

    "The -validatecommand does not work if manually some text is written to the entry widget"

    Kindly show an example of your code that demonstrates the"does not work" behaviour you describe. Ensure you include the part where you change the value of the -validate option from its default, as described in Tk::Entry - VALIDATION:

    none
    Default. This means no validation will occur.

    — Ken