From: John R. <jr...@ce...> - 2004-10-24 20:33:35
|
Just wanted to add that the TransferToWindow and TransferFromWindow functions must also return true. If they don't, TransferData(To|From)Window pops up a dialog box saying that the transfer failed and quits. I've put a slightly modified version of this code on the wxValidator page on the WxPerl Kwiki. Regards, John Ralls On Apr 24, 2004, at 7:59 AM, Mattia Barbon wrote: > On Fri, 23 Apr 2004 12:11:26 +0930 Darryl Ross <bo...@af...> wrote: > > Hello, > >> Sick of me yet? :/ > No, you need to try much harder ;-) > >> Lastest 'issue' with my client program is trying to create a validator >> and assign it to a control. As you might remember from my previous >> messages, I am loading in the screen contents from an XRC file, so it >> is >> not possible to create the validator as part of the object. > You need to create a PlValidator subclass: > > package Wx::Perl::Validator2; > > use strict; > use Wx; > use base 'Wx::PlValidator'; > > sub new { > my $class = shift; > my $var = shift; > my $self = $class->SUPER::new; > > $self->{var} = $var; > > return $self; > } > > sub Clone { > my $self = shift; > my $new = Wx::Perl::Validator2->new( $self->{var} ); > > return $new; > } > > sub Validate { > my( $self, $window ) = @_; > my $validator = $self->validator; > > # check for validity and return true or false > return 1; > } > > sub TransferFromWindow { > my $self = shift; > > ${$self->{var}} = $self->GetWindow->GetValue; > } > > sub TransferToWindow { > my $self = shift; > > $self->GetWindow->SetValue( ${$self->{var}} ); > } > > 1; > > # sample use > my $var; > > $win->SetValidator( Wx::Perl::Validator2->new( \$var ) ); > > Please note that this has been extracted from a largercode base > and not tested; it should give you the direction, nevertheless. > > HTH > Mattia > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek > For a limited time only, get FREE Ground shipping on all orders of $35 > or more. Hurry up and shop folks, this offer expires April 30th! > http://www.thinkgeek.com/freeshipping/?cpg=12297 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |