Hello,
I want to validate the input of an entry widget. Only positive hexadecimal digits shall be allowed.
Here my code:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Data::Dumper;
my $mw = new MainWindow;
$mw->title ("Perl/Tk - Entry Valdiation");
my $entry1 = $mw->Entry ( '-width' => 30,
'-validate' => 'key',
'-validatecommand' =>
sub
{
print Dumper( \@_ );
+
return 0 unless( $_[0] =~ m/^[0-9a-fA-F]
++/ )
} );
$entry1->pack();
MainLoop;
After the input of a valid character I can never remove it again. The first character is always there then. In the dumped output I can see that the character should be gone, but it is still visible in the entry.
Am I doing something wrong? Is it a bug?
Thanks alot for your help.
Greetings,
Dirk
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|