Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture mouse in Firefox

In IE exists .setCapture(); .releaseCapture() functions. What's the equivalent of these functions in Firefox without using jQuery? (my client does not want to use it)

like image 638
Cornel Avatar asked Nov 28 '22 20:11

Cornel


2 Answers

As it has been said above, Firefox does not offer this functionality, and you can work around it by monitoring events on the entire document. To be sure that there is no a better trick, I’ve just checked jQuery UI, and it appears they use the same approach. So for instance if you wanted to capture mouse movements when mouse is down in jQuery, you would do:

$("#someElement").
    mousedown(function() { $(document).mousemove(captureMouseMove) }).
    mouseup(function() { $(document).unbind("mousemove", captureMouseMove) });

function captureMouseMove(event)
{
    // ...
}
like image 197
Jan Zich Avatar answered Dec 14 '22 03:12

Jan Zich


https://developer.mozilla.org/en-US/docs/DOM/element.setCapture

setCapture and releaseCapture were added to Firefox 4 (with the release of Gecko 2) on March 22, 2011. However, WebKit (Chrome/Safari) still lacks these functions.

like image 33
Chip Cressman Avatar answered Dec 14 '22 03:12

Chip Cressman