Open Bug 738105 Opened 12 years ago Updated 2 years ago

DOM 3 Event, mousedown and mouseup default actions

Categories

(Core :: DOM: Events, defect, P5)

defect

Tracking

()

UNCONFIRMED

People

(Reporter: warcraftthreeft, Unassigned)

Details

After receiving a response and specification change for the DOM 3 Event Specification from this discussion:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=8406

The following changes need either discussion or changes in firefox.
http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#event-type-mousedown
http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#event-type-mouseup

Both now have cancelable default actions. This basically allows a developer to effortlessly prevent a context menu or a middle mouse scroll/pan operation among other things that can now be cancelled.

For instance, if a user wanted to stop the context menu they just have to call event.preventDefault(); to stop it. If they want to stop say the middle mouse pan because they're using the middle mouse button they can just called event.preventDefault() on the mousedown event to stop either the momentary scroll or the toggled scroll. (The momentary being when the user holds down the middle mouse button and the toggle one is when the user clicks the middle mouse wheel activating the scroll until they disable it).

This also makes the non-standard contextmenu event kind of worthless.

Not sure how firefox feels implementing the editor draft like this. (Note they still haven't implemented the MouseEvent "buttons" member. I'll submit another bug since this one can probably use it when choosing when you preventDefault()).
I'll update this with a simple test case since it's been a few months:
http://sirisian.com/javascript/dom3mouse.html
Source:
<!doctype html>
<html lang="en">
<head>
<title>Dom 3 Mouse</title>
<script type="text/javascript">
"use strict";

window.onload = function()
{
	var target = document.getElementById("region");
	target.addEventListener("mousedown", function(e)
	{
		e.preventDefault();
	}, false);
	target.addEventListener("mouseup", function(e)
	{
		e.preventDefault();
	}, false);
};
</script>
</head>
<body style="margin: 0;padding: 0;">
	<div id="region" style="width:2000px; height:2000px; background-color:#f0f;"></div>
</body>
</html>

With preventDefault() in both the mousedown and mouseup the browser should not execute any default actions such as middle mouse panning or creation of the context menu when releasing the right mouse button.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.