Opened 15 years ago

Last modified 11 years ago

#3740 closed enhancement

Add mouse button constants — at Version 4

Reported by: guest Owned by: sjmiles
Priority: high Milestone: 1.4
Component: Events Version: 0.9
Keywords: Cc: [email protected]
Blocked By: Blocking:

Description (last modified by bill)

Dojo provides constants for the keyboard keys; dojo.keys. Similarly I recommend adding constants for 'mouse buttons' also, or they can be rolled into dojo.keys.

dojo.mouseButtons = {

LEFT: dojo.isIE ? 1 : 0, MIDDLE: dojo.isIE ? 4 : 1, RIGHT: 2

}

Change History (4)

comment:1 Changed 15 years ago by bill

Milestone: 1.0
Owner: changed from anonymous to sjmiles

Scott, what do you think? Sounds reasonable to me (although my mac only has one button). Although, come to think of it, how is ctrl-button reported on the mac? Does it get normalized to RIGHT?

comment:2 in reply to:  1 Changed 15 years ago by guest

Replying to bill:

Sounds reasonable to me (although my mac only has one button). Although, come to think of it, how is ctrl-button reported on the mac? Does it get normalized to RIGHT?

I put together a quick test page to test out bill's comment and tried Safari, Firefox & Opera on my mac.

event.button values:
Safari, Firefox & Opera : '0' for left mouse button.
Safari: '0' for mouse wheel, probably same for the middle mouse button.
Firefox & Opera : No event for middle mouse button.
No event fired on right mouse button or CTRL+click.

Safari & Firefox : '2' for 'oncontextmenu'.
Opera : Does not fire oncontextmenu at all.

<html>

<head>

<title>Mouse Buttons</title> <script type="text/javascript" src="js/dojo-0.9.0beta/dojo/dojo.js"></script> <script type="text/javascript">

function init() {

var clickclick = dojo.byId("clickclick"); dojo.connect(clickclick, "onclick", handler); dojo.connect(clickclick, "oncontextmenu", handler);

}

function handler(evt) {

dojo.byId("txf").value = evt.button;

}

dojo.addOnLoad(init);

</script>

</head> <body>

<div id="clickclick" style="border:1px solid #000;">Click Click</div> <input type="text" id="txf" />

</body>

</html>

thanks Jayant

comment:3 Changed 14 years ago by sjmiles

Milestone: 1.11.2

comment:4 Changed 14 years ago by bill

Component: GeneralEvents
Description: modified (diff)
Note: See TracTickets for help on using tickets.