Closed Bug 264922 Opened 20 years ago Closed 11 months ago

Event.button returns different values for mouseup and mousedown when right clicking on a Mac

Categories

(Core Graveyard :: Widget: Mac, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: timdown, Unassigned)

References

Details

Attachments

(2 files, 1 obsolete file)

User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 When right-clicking on a Mac, the button property of the mousedown event correctly (according to the DOM spec, at least) returns 2 while the same property for the mouseup event returns 0. Reproducible: Always Steps to Reproduce: 1. Use the following HTML: <html> <head> <script type="text/javascript"> var mouseEventButton = new Object(); var mouseEventDate = new Object(); function mouseEventHandler(e) { var evt = e ? e : event; mouseEventButton[evt.type] = evt.button; mouseEventDate[evt.type] = new Date(); } function reportEvents() { var msg = ""; for (var k in mouseEventButton) { msg += "Button for last " + k + " event: " + mouseEventButton[k] + " at " + mouseEventDate[k].toGMTString() + "<br />"; } document.getElementById("msg").innerHTML = msg; } document.onmousedown = mouseEventHandler; document.onmouseup = mouseEventHandler; document.onclick = mouseEventHandler; document.oncontextmenu = function() { return false; }; setInterval(reportEvents, 500); </script> </head> <body> <p id="msg"></p> </body> </html> 2. Right click on the document. Actual Results: Document reported mousedown button as 2, mouseup button as 0. Expected Results: Reported button as 2 for both events
Attached file The testcase
This worksforme on Linux, so this sounds like a Mac widget code issue..
Assignee: events → sfraser
Component: DOM: Events → GFX: Mac
QA Contact: ian
Attached patch mouseup event fix (obsolete) — Splinter Review
This is the patch we use to fix the right mouse buttonup event. Elsewhere in nsMacEventHandler.cpp the same method is used to properly create the right mousedown event.
Status: UNCONFIRMED → NEW
Component: GFX: Mac → Widget: Mac
Ever confirmed: true
Attachment #194208 - Flags: superreview?(sfraser_bugs)
Attachment #194208 - Flags: review?(mark)
Comment on attachment 194208 [details] [diff] [review] mouseup event fix This is good, but the flow and reassignments are ugly. If it's a middle click with control down, we want NS_MOUSE_MIDDLE_BUTTON_UP, but we'll set mouseButton to two other constants first. In other cases, we [already] do all sorts of extraneous comparisons. There's not really enough context to see it here. Shane, it would help reviews along if you'd give us more (at least 8): cvs diff -u8. Let's get a new patch that leaves it initialized to left-up, then: if (aOSEvent.message == kEventMouseButtonSecondary) else if (aOSEvent.message == kEventMouseButtonTertiary) else if (aOSEvent.modifiers & controlKey) // Macs treat control-left click as context click
Attachment #194208 - Flags: review?(mark) → review-
Are we gonna need something for cocoa widgets here too?
here is a fresh patch based on comments. I've also modified the mousedown handling to match the mouseup handling, and hopefully enough context in the diff
Attachment #194208 - Attachment is obsolete: true
Attachment #194208 - Flags: superreview?(sfraser_bugs)
Attachment #202434 - Flags: review?(mark)
(In reply to comment #5) > Are we gonna need something for cocoa widgets here too? Yes, I think we are.
Assignee: sfraser_bugs → joshmoz
Comment on attachment 202434 [details] [diff] [review] rework based on comments + else if (aOSEvent.modifiers & controlKey) + mouseButton = NS_MOUSE_RIGHT_BUTTON_UP; Uh-oh! I like the logic reorg, but control-leftmouseup is sadly not the same as rightmouseup. This would be tricky to get right, involving saved state and other icky things. Unless it's absolutely necessary, I'd leave control-leftmouseup alone.
Attachment #202434 - Flags: review?(mark) → review-
Assignee: joshmoz → nobody
Blocks: 450553
QA Contact: mac
Product: Core → Core Graveyard
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: