> Hi Benoit,
> 
> Benoît Minisini wrote:
> > If CurrentUser, CurrentProject and CurrentSystem are the objects that
> > change,
> > then they should raise the events, not the module where they are
> > declared. Shouldn't they? An event is the way an object tells the world
> > it has changed.
> >
> > If you can't, then there is something not clear in your design.
> 
> Actually, it was something unclear in my explanation.  Its the whole
> instance that gets changed, for example, FReconnect allows the user to
> change the CurrentProject.  So before it exits, we have
> 
> <code>env.CurrentProject = selectedProject</code>
> 
> where selectedProject is a Project instance and env has a Property
> CurrentProject and
> 
> <code>PRIVATE SUB CurrentProject_Write(Value AS Project)
>   $currentProject = Value
> END</code>
> 
> In other words, I am overwriting the whole instance in "env" (or providing
>  a new replacement pointer, if you prefer). So, more specifically,
> $currentProject doesn't "know" it's been "replaced".
> 
> Benoît Minisini wrote:
> > Anyway, you can register your listeners in an object array in your
> > module, and
> > call specific procedures of these object references when something
> > change. It's more like some sort of "bus".
> >
> > I did that in the IDE. For example, when the project state changes (a new
> > project is loaded, the project enters debugging mode, and so on...), the
> > same
> > procedure is called on all opened forms.
> 
> This sounds like what I may be looking for! Could you provide a bit more of
> a clue where to look as there is a lot of good stuff in the IDE project...
> but there is quite a lot of code too!

Just browse all opened forms and call the same method on it. Use the TRY 
statement, so that if a form does not implement the method, it will fail 
silently.

> 
> Finally, just out of interest, why can't modules raise events?
> 

Because a module is not an object, it is a class with static methods only. And 
a class does not raise events. Even if a class raised events, you would not be 
able to add yours.

Regards,

-- 
Benoît Minisini

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to