On Monday, February 24, 2003, at 05:55 PM, Raymond Irving wrote:
Hi Benoit,
Please note my responses below:
--- Benoit Marchant <[EMAIL PROTECTED]> wrote:Well that points me to other issues I see with the DragEvent right now.
In dynapi2, there was a test in DragEvent.onmousemove to check wether the mouse had moved since the mousedown to make sure it's a drag. I'm afraid if we don't do that it might be difficult to have a layer that both shows a selection and accept drag events, like the list I was mentioning.
In dynapi 3.0 when the onmousedown event is triggered your layer will still be able to receive onmousedown events. Once the user moves the mouse (while still holding the mouse button) that's when the dragging is put into motion. As long as the user does not move the mouse then the DragEvent.startDrag() method will be cancelled on the next onmouseup event.
otherwise, I wouldn't be able to make the difference between a mousedown/up for a selection, and a drag session.
With 3.0 you will be able to do just that by listening to ondragstart,ondragmove and ondragend events
The other thing I added to the DragEvent.onmousedown is a detection if the mousedown happened in a form element. If it does, then I just return. I saw something in MouseEvent._eventHandler about it, but I'm not sure if that's enough ?
I've the complete fix on my machine which will soon make it's way into CVS. The fix will disable dragging of all form elements in ie, ns6, opera, etc. Additional testing will be needed.
The last thing I've added is the ability to restrict "dragability" to a certain area of a layer. I've used a DynArea object to represent circles and rectangles that both implemented
isWithinArea(x,y)
Cool! Why not add it to a class file (e.g. dragarea.js) so it can be included when needed?
What about using Shapes ? Some code still needs to be added to DragEvent:
// check if event occured within one of the areas (if any)
if (lyr.dragAreas && ! lyr.isWithinArea(e.getPageX()-lyr.getPageX(), e.getPageY()-lyr.getPageY())) {
return;
}
So that needs to be done there even though the area stuff is in another file.
Benoit
At last, a comment on the code. I saw in tipstricks.html in the doc section, that it's mentioned to avoid to do for (var and instead use an external variable declaration, I'm not sure why, but it's supposed to be faster to use
Using var inside a for loop will impact performance:
for(var i=0;i<100:i++){ var b=i*2; var c=b*3; }
The problem is with "var c" and "var b" not with "var i". It's faster to do the following:
var b,c; for(var i=0;i<100:i++){ b=i*2; c=b*3; }
Shall we pay attention to that right now ?
I think we need to be careful how we write our codes. Just a tip.
-- Raymond Irving
__________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/[EMAIL PROTECTED]/
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/[EMAIL PROTECTED]/