PDA

View Full Version : setcapture in firefox?



chaz
01-10-2008, 07:00 AM
Hi

I have to convert setcapture from IE into firefox. Here is a script similiar to the one I have to convert. How do I make this work in FireFox???

Looking forward to your reply.

Regards
Chaz

<HTML>
<HEAD>
<TITLE>Track Ball</TITLE>

<STYLE>
<!--
#oTrackBall {
position:absolute;
left:170;
top:200;
}
-->
</STYLE>
<SCRIPT>
<!--
var iRadius = 30;
var iXcenter = 250;
var iYcenter = 170;
var capture = true;

function fnSwitchCapture(obj) {
if (capture) {
capture = false;
obj.releaseCapture();
}
else {
capture = true;
obj.setCapture();
}
}

function doImgMouseMove()
{
var iXdistance = event.x - iXcenter;
var iYdistance = event.y - iYcenter;
var distance = Math.sqrt(iXdistance * iXdistance + iYdistance * iYdistance);
oTrackBall.style.left = iXcenter + iRadius * iXdistance / distance;
oTrackBall.style.top = iYcenter + iRadius * iYdistance / distance;
}
-->
</SCRIPT>
</HEAD>
<BODY onload="oTrackBall.setCapture()" onclick="fnSwitchCapture(oTrackBall)"> <BR>
<CENTER><H2>Simple Animation with setCapture() and releaseCapture()</H2></CENTER>
<IMG ID="oTrackBall" onmousemove="doImgMouseMove()" SRC="black.gif" alt="black sphere">
</BODY>
</HTML>

Mr Moo
01-10-2008, 10:09 AM
setCapture and releaseCapture are IE specific non-standard add-ons. There is a chap called Stephen Stchur who is developing a framework called Gimme (http://www.codeplex.com/gimme/Wiki/Recent.aspx) which, in it's latest unreleased version (Caspian) has x-browser mouse capture functionality. I came across it a couple of days ago and I have not tested it, but I had a brief look at the code and it looks like it just may work.