#3740 closed enhancement (fixed)
Add mouse button constants
Reported by: | guest | Owned by: | Eugene Lazutkin |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Events | Version: | 0.9 |
Keywords: | Cc: | [email protected]… | |
Blocked By: | Blocking: |
Description (last modified by )
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 (28)
comment:1 follow-up: 2 Changed 14 years ago by
Milestone: | → 1.0 |
---|---|
Owner: | changed from anonymous to sjmiles |
comment:2 Changed 14 years ago by
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 13 years ago by
Milestone: | 1.1 → 1.2 |
---|
comment:4 Changed 13 years ago by
Component: | General → Events |
---|---|
Description: | modified (diff) |
comment:5 Changed 13 years ago by
I think the best thing would be to implement this in dojo.fixEvent
comment:6 Changed 12 years ago by
Milestone: | 1.2 → 1.2.1 |
---|
comment:7 Changed 12 years ago by
Milestone: | 1.2.1 → 1.3 |
---|
1.2.1 is only for critical bugs that we find in the 1.2 release; nothing should be marked as 1.2.1 until after we release 1.2
comment:8 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.3 → future |
Owner: | changed from sjmiles to James Burke |
comment:9 Changed 12 years ago by
BTW, when fixing this be careful to get IE8 handling right. My guess is that IE8 in non-quirks mode uses the standard key codes (although I haven't tested it).
comment:10 Changed 12 years ago by
IE uses a bitset to represent all currently pressed buttons. It is not as simple as defining constants. I already had a problem with DnD when the end user pressed by mistake/clumsiness two or more buttons simultaneously and forced an app in the incorrect state.
See #8603 for relevant links.
comment:11 Changed 12 years ago by
Milestone: | future → 1.4 |
---|---|
Owner: | changed from James Burke to Eugene Lazutkin |
Eugene said he could do this for 1.4, so I'm taking him up on his offer :-).
Also, he said that he tested IE8 in quirks mode and standards and the buttons work the same as IE6, so we don't have to branch based on IE version.... so ignore my comment above.
comment:12 Changed 12 years ago by
Status: | new → assigned |
---|
comment:13 Changed 12 years ago by
comment:14 Changed 12 years ago by
comment:15 Changed 12 years ago by
comment:16 Changed 12 years ago by
comment:17 Changed 12 years ago by
comment:18 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
While I tested all, please retest Tree DnD, Grid, and PlottedDnd to double check, and reopen the ticket if you find any negative deviations from the previous behavior.
comment:19 Changed 12 years ago by
comment:20 Changed 12 years ago by
comment:21 Changed 12 years ago by
comment:22 Changed 12 years ago by
Please chime in, if you think that names can be selected better, or you have any other comments.
comment:23 Changed 12 years ago by
comment:24 Changed 12 years ago by
I did a cursory check of Tree DnD, seems to be working well. Thanks for fixing this ticket. Oh, I also updated the API comment format in the DnD code to match our style guidelines.
comment:25 Changed 12 years ago by
comment:26 Changed 9 years ago by
I wanted to use dojo.mouseButtons to check if left mouse button is clicked and I found out that Chrome uses 1 for left, 2 for middle and 3 for right mouse button. So I get false value for it.
comment:27 Changed 9 years ago by
Actually, I tested in Opera and Firefox on Ubuntu 11.04 (Chrome is also on the same system) and it's the same as described in my previous comment: left mb code is 1, middle 2 and right 3. I'd be glad to see this issue fixed as soon as possible.
comment:28 Changed 9 years ago by
Are you saying chrome, firefox, and opera all use different constants depending on the platform (windows/mac vs. ubuntu)??
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?