Not quite, when an event occurs which should be handled by the moderator, you need to have the event source notify the event moderator of the event and also identify both the event and the instigator. Let the moderator decide what to do about it. Sort of like telling your boss about a problem in the department, the boss will deal with it.
Glenn
>So, to talk to another class I would call the function in the mediator, passing the name of the class, which will in turn call the function in the relevent class?
>
>Kev
>
>>Sure, here is an example I put together for you, somehow it even works!
>>
>>Local lof As Form
>>
>>lof = Createobject('MediatorForm')
>>lof.Show(1)
>>
>>
>>Define Class MediatorForm As Form
>> Visible = .T.
>> AutoCenter = .T.
>> Height = 80
>> Width = 160
>> Caption = 'Mediating Container'
>>
>> Add Object tickletext1 As tickletext ;
>> WITH ;
>> top = 10,;
>> left = 10, ;
>> visible = .T.
>>
>>
>> Add Object tickletext2 As tickletext ;
>> WITH ;
>> top = 10, ;
>> left = 80, ;
>> visible = .T.
>>
>> Function showentry
>> Lparameters tcName
>> If tcName = This.tickletext1.Name
>> This.tickletext2.Value = This.tickletext1.Value
>> Else
>> This.tickletext1.Value = This.tickletext2.Value
>> Endif
>> Endfunc
>>
>>Enddefine
>>
>>
>>Define Class tickletext As TextBox
>> Width = 70
>>
>> Function LostFocus
>> This.Parent.showentry(This.Name)
>> Endfunc
>>Enddefine
>>
>>
>>Glenn
>>>Hi
>>>
>>>Have you got any examples/notes on this method? I've never tried it before.
>>>
>>>Thanks
>>>Kev
>>>
>>>>I believe that it is "Best Practice" to invoke a mediator for this purpose. The parent object should communicate with both objects. In this case the object which triggers the event should notify the Parent object and then the parent object should take any necessary actions with it's children objects.
>>>>
>>>>Glenn
>>>>
>>>>>Hi
>>>>>
>>>>>What's the best way to do the following? I have an object that needs to call methods in another object.
>>>>>
>>>>>Is it best to create the object you want to talk to, in a property on the object?
>>>>>
>>>>>Or are there other/better ways?
>>>>>
>>>>>Thanks
>>>>>Kev