[Gambas-user] A few questions

Doriano Blengino doriano.blengino at ...1909...
Thu Sep 25 08:45:20 CEST 2008


Benoit Minisini ha scritto:
> On mercredi 24 septembre 2008, Doriano Blengino wrote:
>   
>> 	STATIC SUB *Attach* ( _Object_ AS Object, _Parent_ AS Object, _Name_ AS
>> String )
>>
>> "it depends
>> in which class the instruction attach() is compiled".
>>     
> No. Object.Attach() will send events raise by 'Object' to 'Parent', by 
> using 'Name' as event handler prefix. So it does not depend on the context. 
> The same Attach() call will always do the same thing whereever it is run.
>   
You are right. The search about method names is performed on Parent.

> PRIVATE $hObs AS Observer
>
> PUBLIC SUB Register(hObject AS Object)
>
>   $hObs = NEW Observer(ME)
>   Object.Attach($hObs, hObject, "whatever")
>
> END
>   
I tried, but the GetPage event does not reach the calling form (but my 
gambas version is 2.0.0). I have no time now, but this evening I will 
send you a project to try yourself, if you want.
In theory, this is straightforward: by creating an observer, and 
attaching it somewhere else, that "else" should receive events. It seems 
instead that this does not work.
The problem is, that it is difficult to understand where events go, if 
they are there. I mean, after doing your suggested modification, and 
stepping through "raise getPage", I see no handlers are called, but I 
can no more see the $hObs internal behaviour. May be a 
"$hObs.debug=true", or the possibility to do "print $hObs.Parent" could 
help.

> You can have only one registered object simultaneously, but it should not 
> matter for your use of that.
>   
Yes, I want only one object registered (think at having two print 
processes which print on the same page... ah ah ah...).
But if this should be wanted, then a new observer on top on the current 
observer could work...

Best regards,
Doriano Blengino






More information about the User mailing list