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! -- erik colson ecocode.net