Yes, but as I still miss sg. Apologies. As I understand (see code below): >From main I call myApp->new() -> myApp->SUPER::new() < here I can not pass my $obj for the above reason.
myApp->SUPER::new() calls internally OnInit, and no $obj has room in this process. It returns me an empy HASH. In myApp->new() I can initialize Frame and pass $obj to frame, but I have to return a myApp object, and it is initialized w/o my $obj. So, again, I can not find it is Frame. Here is a code extract with comments. http://pastebin.com/RDYzgwhs Thank you! On Sat, Oct 23, 2010 at 10:27 PM, Johan Vromans <jvrom...@squirrel.nl>wrote: > Laslo Forro <getfo...@gmail.com> writes: > > > my $app=myApp->new($obj) > > So you pass an object arg to your derived class. > > > sub new { > > my ($ref,$obj)=...@_; > > This is the constructor os your derived class. > > > my $self=$ref->SUPER::new($obj); > > Here you pass the object to the super class constructor. However, > Wx::App does not take an object as its argument. So it complains: > > > sub must be a CODE reference at .../Wx/App.pm line 36. > > > I would like to use this object from the frame I have created. Eg. I > would > > like to access the object from an event sub, like > > sub OnClick { > > my ($self,$even)=...@_; > > $self->{myObject}->do_this()… > > } > > > > For this, in the subclass constructor, use something similar to: > > sub new { > my ( $ref, $obj ) = @_; > my $self = $ref->SUPER::new; > ... > my $frame = MyFrame->new; > $frame->{Object} = $obj; > ... > $self->SetTopWindow($frame); > $frame->Show; > ... > } > > -- Johan >