i just want to add here a complain on my own :)

quantifier inside the wxperl validators dont seem to work,
e.g. "^/d{1,3}$" doesnt stops on the third digit
and the method SetBellOnError also doesnt seem to work,
i cant turn the bell of with it under win.

best
herbert

Am 20.03.2011 12:14, schrieb Erik Colson:
> Ehlo,
> 
> I've used Wx::Perl::TextValidator to limit accepted keypresses in
> TextCtrl. This has been enough for controls till now but as I'm moving
> to a broader user base I need to filter with more intelligence.
> 
> Now I need to check that the user enters data to correspond to this
> regex: (M|O|(NC?)|(\d+)). So at every moment the string in the control
> must match this regex. What would be the recommended way to code this ?
> Can this be done with a Validator ?
> 
> Following is working by intercepting the EVT_TEXT event on the control:
> (Ugly code, but working and explaining what I wish for...)
> 
>   EVT_TEXT (
>       $self->gridInStock, $control, sub {
>           my ($self, $event) = @_ ;
>           my $curValue = $control->GetValue() ;
>           $curValue = uc($curValue) ;
>           if ( $curValue =~ m/(M|O|(NC?)|(\d+))/ ) {
>               $curValue = $1 ;
>           } else {
>               $curValue = "" ;
>           } ;
>           my $curPos = List::Util::max( $control->GetInsertionPoint(),
>                                         length($curValue) ) ;
>           $control->ChangeValue("$curValue") ;
>           $control->SetInsertionPoint($curPos) ;
>       })
> 
> Thanks for help!
> 

Reply via email to