[Gambas-user] How to stop an Observer?

tobias tobiasboe1 at ...20...
Mon Jul 11 22:56:26 CEST 2011


On 11.07.2011 22:39, Benoît Minisini wrote:
>> On 11.07.2011 20:47, tobias wrote:
>>> hi,
>>>
>>> i wonder how to stop an observer from raising events? my code
>>> demonstrative code looks like this:
>>>
>>> (gambas2)
>>>
>>> PRIVATE hObs AS Observer
>>>
>>> PUBLIC SUB ObserveSubject(hSubject AS TextBox)
>>>
>>>      IF hObs THEN
>>>
>>>        ReleaseSubject()
>>>
>>>      ENDIF
>>>      hObs = NEW Observer(hSubject)
>>>
>>> END
>>>
>>> PUBLIC SUB ReleaseSubject()
>>>
>>>      ???
>>>
>>> END
>>>
>>> i think, i'm missing something very basic here...
>>>
>>> regards,
>>> tobi
>> oh, i just noticed the note in the online doc which is not present in my
>> offline one:
>> The observer object is attached to the observed object, and is freed
>> only when the observed object is freed too.
>>
>> seems that there is no possibility without destroying the control. is
>> there a way to copy an entire object, so i can create a new TextBox with
>> the same property values?
>>
> Why do you want to stop the observer?
>
as usual, i'm just interested ;)
in my example, the raising of observer events may become unnecessary or 
unwelcome because they restrict a control (i wanted to try another way 
of limiting the input of a textbox to number only, for example).
now, i'm discovering
FOR EACH s IN Class.Load("TextBox").Symbols
to copy the entire textbox before deleting it to get rid of the events :)

regards,
tobi




More information about the User mailing list