From: Mark W. <ma...@ne...> - 2006-07-25 07:17:18
|
Hello, Further investigation has revealed that $this->FindWindow( $name ) returns a HASH ref for all other controls I have tested but ONLY returns a SCALAR ref for controls of type Wx::Grid. I use this _BAD_ method of reblessing as a way of initialising subclassed controls (as below) that I am loading from XRC and have no other way of initialising them. SubclassFactory provides a way to override the default ->new() method (with no parameters), but there is no other way to override a Create or Show to provide any further customisation. So I am forced to manually Init each control in my OnInitDialog handler. if (my $grid = $self->FindWindow('DiscountGrid')) { bless $grid, 'Grid::DiscountGrid'; print "Grid::DiscountGrid => $grid\n"; $grid->InitControl( $self ); } I suppose I could prevent the reblessing by simply declaring the subclassing in the XRC definition but I would still have the problem of FindWindow returned a SCALAR instead of a HASH and I need the HASH as I use a lot of code like below: $self->{Option1} = $var; Can anyone offer any pointers where I can start looking or possible alternative solutions. Thanks in advance. Mark -----Original Message----- From: Mattia Barbon [mailto:mat...@li...] Sent: 24 July 2006 09:13 PM To: Mark Wardell Cc: 'wxperl-users' Subject: Re: [wxperl-users] Differences using wxWidgets 2.7.0 On Mon, 24 Jul 2006 19:30:41 +0200 "Mark Wardell" <ma...@ne...> wrote: Hello, > I have some code as below: > > if (my $grid = $dialog->FindWindow(MyGrid')) { > bless $grid, 'Grid::MyGrid'; > print "Grid::MyGrid => $grid\n"; > } > > Using wxPerl 0.54 on wxWidgets 2.6.3 I get: > Grid::MyGrid => Grid::MyGrid=HASH(0x7015a00) > > Using wxPerl 0.54 on wxWidgets 2.7.0 I get: > Grid::MyGrid => Grid::MyGrid=SCALAR(........) Honestly I have no idea why this should be so; the different wxWidgets version should not influence this. Regards Mattia P.S.: reblessing like this is _BAD_ |