From: Mark W. <ma...@ne...> - 2006-10-17 14:59:10
|
Although the last code would work as a hash ref. as you requested, a 'better' way to subclass would be as follows: sub new { my ($class) = @_; # instead of using the following # which would return a reference to a 'Wx::Frame' #my $newFrame = Wx::Frame->new; # use this to create a reference to MyFrame # which is a derived class of Wx::Frame my $newFrame = $class->SUPER::new; ... } > -----Original Message----- > From: wxp...@li... > [mailto:wxp...@li...] On Behalf > Of Peter Gordon > Sent: 17 October 2006 02:30 PM > To: wxp...@li... > Subject: [wxperl-users] Advice needed > > In the example below, I create a new Frame, where the frame > definition is given in an xrc file. Normally, a new frame > would give a HASH reference, whereas LoadFrame gives a SCALAR > reference. > > So the question arises: I have some private data, var, that I > would like to store in this class. How do I do it? > $newFrame->{var} = $var fails because of the scalar reference. > > Thanks, > > Peter > > package MyFrame; > use vars qw(@ISA); > > @ISA = qw(Wx::Frame); > > use Wx qw(:everything); > use Wx::Event qw(:everything) ; > > sub new { > my $xrc = Wx::XmlResource->new(); > $xrc->InitAllHandlers(); > $xrc->Load("appliance.xrc"); > > my $newFrame = $xrc->LoadFrame(undef,'ID_FRAME') ; > > my $tree = $newFrame->FindWindow('ID_TREECTRL_MENU') ; > my $var = "Test Var" ; > > $newFrame->{var} = $var ; > return $newFrame,; > } > > > > > -------------------------------------------------------------- > ----------- > Using Tomcat but need to do more? Need to support web > services, security? > Get stuff done quickly with pre-integrated technology to make > your job easier Download IBM WebSphere Application Server > v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057& > dat=121642 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |