On Wed, 2002-05-08 at 15:21, Rick Ovenden wrote:
> Hi Dmitry,
>
> In VB events how are widgets other than $self referenced? For example; in
> the onClick event of Button1 how is the text property of Button2 referenced?
> The only way I have found to make it work so far is to set a variable in the
> onCreate event for Button2 [ $prima::CancelButton = $self; ] which I can
> then use in the onClick event of Button2 [
> $prima::CancelButton->text("Exit"); ]. I'm sure this is not the correct way
> to do it.
>
> Apologies if this a stupid question. I'm new to Perl and I can't find an
Well, we all were learning once upon a time...
> example anywhere in the Prima-1.05 documentation or examples.
In fact, the way you used isn't that bad in cases where one need a
shortcut to an object.
Otherwise you must use the fact that for any widget named 'WidgetXX'
and inserted into a widget stored in $owner (for instance) you can alway
reference it as:
$owner->WidgetXX;
For example:
$owner->WidgetXX->size(100, 100);
And, of course, any owner is reachable via owner() method. So, in a
simple case like the one I have attached you can reference a neighboring
widget as:
$self->owner->WidgetXX;
-- /Voland Vadim Belman
# VBForm version file=1.1 builder=0.1
# [preload]
sub
{
return (
'Button1' => {
class => 'Prima::Button',
module => 'Prima::Buttons',
profile => {
origin => [ 104, 124],
size => [ 96, 36],
owner => 'Parent',
onClick => Prima::VB::VBLoader::GO_SUB('my $self = $_[0];
$self->owner->Button2->pressed(
! $self->owner->Button2->pressed
);','Button1', 'onClick'),
name => 'Button1',
}},
'Parent' => {
class => 'Prima::Window',
module => 'Prima::Classes',
parent => 1,
profile => {
origin => [ 558, 148],
originDontCare => 0,
bottom => 148,
width => 499,
name => 'Parent',
sizeDontCare => 0,
height => 359,
left => 558,
size => [ 499, 359],
}},
'Button2' => {
class => 'Prima::Button',
module => 'Prima::Buttons',
profile => {
origin => [ 244, 124],
size => [ 96, 36],
owner => 'Parent',
onClick => Prima::VB::VBLoader::GO_SUB('my $self = $_[0];
$::application->close;','Button2', 'onClick'),
name => 'Button2',
}},
);
}
Received on Wed 08 May 2002 - 17:45:07 CEST
This archive was generated by hypermail 2.2.0 : Sat 19 Mar 2011 - 18:35:04 CET