Hi!
I'm having a bit of a problem.
I'm trying to make my layers snap to a 10x10 grid for ease of use.
I'm already making the layers come to the foreground when they are
clicked (onmousedown).
Here's the code:
<SCRIPT language = \"JavaScript\">
<!--
function bringToFront(obj)
{
var o;
var t;
var topZ = 0;
o = obj.parent.children;
for (var i = 0; i < o.length; i++)
{
t = o[i].getZIndex();
o[i].setZIndex(t - 1);
if (t > topZ) topZ = t;
}
obj.setZIndex(t);
}
function snapToGrid(obj)
{
var Top;
var Left;
Top = obj.top;
Top = Top / 10;
Top = int(Top);
Top = Top * 10;
Left = obj.left;
Left = Left / 10;
Left = int(Left);
Left = Left * 10;
obj.moveTo(Left, Top);
}
//-->
</SCRIPT>
I have the event listener set up:
listener$DivID = new
EventListener(DynAPI.document);
listener$DivID.onmousedown =
function(e)
{
bringToFront(div$DivID);
}
listener$DivID.onmouseup = function(e)
{
snapToGrid(div$DivID);
}
div$DivID.addEventListener(listener$DivID);
DragEvent.enableDragEvents(div$DivID);
This is actually perl code that generated the pages (CGI), so $DivID
is an arbitrary name of the DIV block.
However for some reason, when I add the onmouseup even handler that
calls "snapToGrid(obj)", I am no longer able to "drop" the DIV. It
keeps the mouse movements even after I let go of the button. What is
going wrong, and is there a work-around?
Thanks!
Gordan
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help