Lunna,
        I am the originator of the message, and I would like to thank you very much
for he fix. It seems to be working like a dream.

        I suggest it is included in the next update of DynAPI, as it seems like
half of it is already in there (DynAPI 2.54).
The only thing missing is two lines in the DynLayer constructor, which as
you specified are:

In dynlayer.js, make the DynLayer function end with:

        // These aren't used unless listeners.js is included
        this.eventListeners = [];
        this.hasEventListeners = false;
};

        I have been working on some complex stuff recently, and this makes their
functionality possible.

Thanks again,

Aristotelis Joannou
Senior Developer
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Tel: 0870 3332966
Fax: 0870 3332967
Mob: 07779 299589
Web: http://www.solcara.com/

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Joachim Lundgren
Sent: 18 August 2001 14:57
To: [EMAIL PROTECTED]
Subject: Re: [Dynapi-Dev] [ dynapi-Bugs-425789 ] Events Fire On All Objects
(same subcls)

At 2001-08-17 18:10, you wrote:
>Bugs item #425789, was opened at 2001-05-20 19:21
>You can respond by visiting:
>http://sourceforge.net/tracker/?func=detail&atid=105757&aid=425789&group_id
=5757
>
>Category: DynAPI 2 Events
>Group: None
>Status: Open
>Resolution: None
>Priority: 5
>Submitted By: a.joannou (conan1)
>Assigned to: Jordi Ministral (dodoron)
>Summary: Events Fire On All Objects (same subcls)
>
>Initial Comment:
>        On objects made from other objects which in turn are made from the
DynLayer (e.g.
>scrollPane),  eventListeners placed on one object, fire on ALL of them as
outlined in the following
>example. Why is this? Is there a solution?
>        This problem is apparent on any objects created in the same way
(e.g. if I create an
>object 'A' based on DynLayer, and then create an object 'B' based on object
'A', the same problem
>occurs).
>        This makes programming of complex objects IMPOSSIBLE.
>
>Looking forward to your prompt reply.
>Deli.
[snip]


The problem is the objects share the same eventListener array [in your
example it can be verified with an alert(scrollpane1.eventListeners ===
scrollpane2.eventListeners); line].

So, how to fix it? I wasn't able to find a nice way to do it so the
following kludge will do for now...

(Because eventListeners are a rather fundamental aspect of the code it is
less of a kludge than it really is :-)

In dynlayer.js, make the DynLayer function end with:

        // These aren't used unless listeners.js is included
        this.eventListeners = [];
        this.hasEventListeners = false;
};

and change one line in listeners.js:
DynObject.prototype.addEventListener=function(listener) {
        if(!this.hasEventListeners) { this.eventListeners = []; }       //
<- This changed
        this.hasEventListeners = true;
        for (var i=0;i<this.eventListeners.length;i++) if
(this.eventListeners[i]==listener) return;
        this.eventListeners[this.eventListeners.length]=listener;
}

NB: I only made a quick-and-dirty test-case, and I got the desired results
with these changes. Please check so it doesn't break anything else!

/Lunna


_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev


_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-dev

Reply via email to