Cancel highlight/html5 drag/autoscroll events that are in progress (undo events started by mousedown)

I have a gesture addon and the trigger to is the primary mouse button + wheel. Once the wheel is scrolled while the primary mouse button is held, all further mouse events are blocked. Until the primary mouse button is released.

However I need to cancel the current highlight in progress, the html5 drag in progress, the autoscroll in progress if any, and ideally any other events initiate by the mousedown. The way I currently do it is use nsIDOMWindowUtils to send a mouseup event (and tap into code to cancel autoscroll) but I dislike this method:

setTimeout(function () {
    var cwin = Services.wm.getMostRecentWindow('navigator:browser').gBrowser.selectedBrowser.contentWindow;
    var utils = cwin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
    utils.sendMouseEvent('mouseup', 1, 1, triggerButtonNumber, 1, 0);
    console.error('done');
}, 4000)

I was wondering if anyone could brainstorm with me some other ideas please?

I have tried suppressing events with nsIDOMWindowUtils :: supressEventHandling but on unsupress the events continue from where they left off.

Basically what I’m trying to do is undo/cancel/preventDefault any events started by the “Down” of the first mouse button.

The first (and pretty much only) thing that comes to mind is simulating an Esc keypress. (Almost?) all of such actions are cancelled by hitting esc.

1 Like

Thanks that’s a great idea! It might also stop the page loading :frowning: I’ll play with it to see if I can make it stop everything but the page load it’s a great idea!

Good point, I didn’t consider esc might do a little too much.