Patches item #433195, was updated on 2001-06-14 10:59
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305757&aid=433195&group_id=5757
Category: DynAPI 2 Extension
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Scott Severtson (scottsevertson)
Assigned to: Nobody/Anonymous (nobody)
Summary: DragDrop requirements
Initial Comment:
Currently, drop events are fired only if the event
source layer is release entirely within the listening
layer.
Traditional drag-and-drop at the OS level accepts drop
events if an element is dragged and released with just
the mouse pointer inside the target. This includes
Windows, Macintosh, and most X apps that support drag
and drop.
The following changes will make this requirements
change take effect.
dynapi\event\dragevent.js, line 121:
FROM:
if (lyr.parent.DragDrop) lyr.parent.DragDrop(lyr);
TO:
if (lyr.parent.DragDrop) lyr.parent.DragDrop(lyr, e);
dynapi\ext\dragdrop.js, lines 10-26:
FROM:
DynObject.prototype.DragDrop=function(s){
if (!this.children.length>0) return false;
var ch,chX,sX,sY;
for (var i in this.children) {
ch=this.children[i];
chX=ch.getPageX();
chY=ch.getPageY();
sX=s.getPageX();
sY=s.getPageY();
if (chX<sX && chX+ch.w>sX+s.w && chY<sY &&
chY+ch.h>sY+s.h) {
if (ch.DragDrop(s)) return true;
ch.invokeEvent("drop");
return true;
}
}
return false;
};
TO:
DynObject.prototype.DragDrop=function(s,e){
if (!this.children.length>0) return false;
var ch,chX,chY,eX,eY;
for (var i in this.children) {
ch=this.children[i];
chX=ch.getPageX();
chY=ch.getPageY();
eX=e.getX();
eY=e.getY();
if (chX<eX && chX+ch.w>eX && chY<eY &&
chY+ch.h>eY) {
if (ch.DragDrop(s,e)) return true;
ch.invokeEvent("drop");
return true;
}
}
return false;
};
Tested on Windows NT, IE 5.01 and NS 4.72.
Test Case:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"
SRC="dynapi/dynapi.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript"><!--
DynAPI.setLibraryPath("dynapi/lib/");
DynAPI.include("dynapi.api.*");
DynAPI.include("dynapi.event.*");
DynAPI.include("dynapi.ext.dragdrop");
//--></SCRIPT>
<SCRIPT LANGUAGE="JavaScript"><!--
DynAPI.onLoad = function() {
myTarget1= new DynLayer
('Target1',200,300,50,50,'green')
mySource1 = new DynLayer
('Source1',250,200,20,20,'#00FF99')
myListenerDrop=new EventListener(myTarget1)
myListenerDrop.ondrop=function(e) {
alert("dropped");
}
myTarget1.addEventListener(myListenerDrop)
DragEvent.enableDragEvents(mySource1)
DynAPI.document.addChild(myTarget1)
DynAPI.document.addChild(mySource1)
}
//--></SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
----------------------------------------------------------------------
>Comment By: Scott Severtson (scottsevertson)
Date: 2001-06-14 12:15
Message:
Logged In: YES
user_id=159783
Sounds good - I will defer to a formal project member, as
they probably have a better sense of where the flag should
live/naming conventions.
Just a heads up -- I've found a bug in drag and drop - if
the drag Target is added to a document AFTER the drag
Source, no drop event is fired. I'll do my best to track it
down and submit a fix.
----------------------------------------------------------------------
Comment By: Ernest MacDougal Campbell III (emc3)
Date: 2001-06-14 12:05
Message:
Logged In: YES
user_id=29866
Good catch. I'd like to suggest, however, having some sort
of flag to allow the old behavior, for those who might want
it. Sure, the developer could check the layer boundries on
his own in his ondrop code, but if we've already got it
coded, why make everybody re-invent the wheel?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305757&aid=433195&group_id=5757
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev