when should I create child objects?



I'm attempting to build a Goo::Canvas::Group subclass. It has a 'displayName' property, and would show the displayName using a Goo::Canvas::Text object.

###### in CanvasExpand.pm ######
package CanvasExpand;

use Glib::Object::Subclass('Goo::Canvas::Group',
    properties => [
        Glib::ParamSpec->string(
            'displayName','','',
            'default_value',
            [qw/readable writable/]
        )
    ],
);

sub INIT_INSTANCE {
    my $self = shift;
    my $name = $self->get('displayName'); # here gots 'default_value'
    Goo::Canvas::Text->new($self,$name,0,0,-1,'center');
}

##################

However, while creating the Text object in INIT_INSTANCE function, the displayName property remains to be uninitialized: the default value is retrieved, rather than the value provided in constructor. So, when should I build all children?


Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up now.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]