----- Original Message -----
Sent: Thursday, April 05, 2001 4:31
PM
Subject: Re: [Dynapi-Help] How do I drop
stuff on a child layer (a layer that's ontop of another layer)???
Hi,
What dragdrop.js does, is loop through all the
children of the document, and check if they overlap with the source item. I
added one layer of children checking, so if a layer has children they will be
checked for overlapping.
In the longrun I think a better way to do this,
would be to see which layers have an eventlistener added to them, and only
check them, instead of checking all layers like we do now.
Do we have a collection of objects having an
eventlistener now? (so we could do DynAPI.document.hasListener.length
)
If you use this version of dragdrop.js it will
support one level of children. (Not children of children etc.):
/*
DynAPI
Distribution
DragDrop Extension
The DynAPI Distribution is
distributed under the terms of the GNU LGPL license.
Requirements:
dynapi.api.*
*/
DynObject.prototype.DragDrop=function(s){
if
(!this.children.length>0) return;
for (var i in this.children)
{
var ch=this.children[i];
if (ch.x<s.x
&& ch.x+ch.w>s.x+s.w && ch.y<s.y &&
ch.y+ch.h>s.y+s.h){
if
(!ch.children.length>0)ch.invokeEvent("drop");
else{
for
(var i in ch.children) {
var
chChild=ch.children[i];
if ((ch.x+chChild.x)<s.x
&& (ch.x+chChild.x)+chChild.w>s.x+s.w &&
(ch.y+chChild.y)<s.y &&
(ch.y+chChild.y)+chChild.h>s.y+s.h)chChild.invokeEvent("drop");
else
ch.invokeEvent("drop");
};
};
};
};
};
DynDocument.prototype.DragDrop=DynObject.prototype.DragDrop;
If anyone has an idea on how to make the function
recursive so it checks more than one layer deep, I'd be
interested.
Another thing it does is check the exact size, so
the event only fires if the block is dropped completely on the target from all
sides, and not only top and left as before.
I also changed the source of the example a
little, to demonstrate a more efficient way of using eventlisteners. (using
one for all events).
(attached)
I'll put the examples up when I upgrade to the
latest code.
Cheers,
Richard Bennett
----- Original Message -----
Sent: Thursday, April 05, 2001 6:01
PM
Subject: [Dynapi-Help] How do I drop
stuff on a child layer (a layer that's ontop of another layer)???
All I want to do is drop something on a layer
that is within (is a child of) another layer.
However, the 'ondrop' event for the child layer
does not fire. I've included a
***very*** simple example that I
think should work...but it doesn't. Is
this a problem with event bubbling in the DynAPI or do I just not
know
how to do this?
Thanks for any ideas.
Chris
Shreve