Ticket #3740 (new enhancement)

Opened 12 months ago

Last modified 8 weeks ago

Add mouse button constants

Reported by: guest Owned by: sjmiles
Priority: normal Milestone: 1.2
Component: Events Version: 0.9
Severity: normal Keywords:
Cc: jayant.b.sai@…

Description (last modified by bill) (diff)

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

follow-up: ↓ 2   Changed 12 months ago by bill

  • owner changed from anonymous to sjmiles
  • milestone set to 1.0

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?

in reply to: ↑ 1   Changed 12 months 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

  Changed 5 months ago by sjmiles

  • milestone changed from 1.1 to 1.2

  Changed 2 months ago by bill

  • component changed from General to Events
  • description modified (diff)

  Changed 8 weeks ago by guest

I think the best thing would be to implement this in dojo.fixEvent

Note: See TracTickets for help on using tickets.