Closed Bug 340870 Opened 18 years ago Closed 18 years ago

Control-click doesn't bring up contextual menu in Cocoa widgets

Categories

(Core :: Widget: Cocoa, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mark, Assigned: jaas)

Details

Attachments

(3 files, 2 obsolete files)

Steps to reproduce:
1. Command-click on something.

Expected behavior:
See a contentless contextual menu popup window (in its present broken state)

Observed behavior:
Nothing.  Actually, the contextual menu occasionally flickers open but disappears immediately.
Summary: Command-click doesn't bring up contextual menu in Cocoa widgets → Control-click doesn't bring up contextual menu in Cocoa widgets
Attached patch fix v1.0 (obsolete) — Splinter Review
just threw this together, not requesting review until I've had more time to think about it
Attached file stack trace #1
I figured something fishy was going on here. A context menu is being shown on control-click, its just being immediately closed. To figure out what was closing it, I started up the browser in gdb and set a breakpoint at orderOut:, which is what would be called on a context menu to close it. Then I control-clicked. This is the stack I got, posting it here for my own reference if nothing else.

Fix v1.0 is almost certainly not what we want. We need to figure out why the context menu is being closed and stop that from happening.
Attached patch fix v2.0Splinter Review
This is the right way to deal with the problem. We always want to send gecko a mouse down event for any mouse down (right or left), and in some cases we want to send a context menu event afterwards. The problem with sending context menu events from menuForEvent: is that the mouseDown: message comes after menuForEvent:, but rightMouseDown: comes before menuForEvent: (Cocoa oddity). Because of this, menuForEvent would put up a context menu on control-click, but mouseDown: would immediately close it since it unaware that some other native event just put the context menu up.

This patch does away with menuForEvent: altogether and handles context menu events in the mouse button handlers. I used the GTK2 impl as a reference.
Attachment #224972 - Attachment is obsolete: true
Attachment #225104 - Flags: review?(mark)
I think menuForEvent: is used to invoke context menus by other means that clicking (for example, by VoiceOver). If that's the case, we need to use it.

How about inventing a BOOL that will make sure the useless click event after the menuForEvent: is disregarded instead?  Overall, I'd find that cleaner than relying on stuff happening a mousedown event.
Attachment #225104 - Flags: review?(mark)
Attached patch fix v3.0 (obsolete) — Splinter Review
Attachment #225299 - Flags: review?(mark)
Attachment #225299 - Flags: review?(mark)
Attached patch fix v3.1Splinter Review
Attachment #225299 - Attachment is obsolete: true
Attachment #225312 - Flags: review?(mark)
Comment on attachment 225312 [details] [diff] [review]
fix v3.1

Tiny nit, this leaks the stored event, if there is one, when the child view goes away, right?
Comment on attachment 225312 [details] [diff] [review]
fix v3.1

Release mLastMenuForEventEvent (nice name) when deallocing the childview.
Attachment #225312 - Flags: review?(mark) → review+
yep, fixed on checkin. this is landed on trunk.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
While control-click does now bring up a context menu, right click still does not. Not sure if I should comment here or open a new bug. FWIW, right click does create a context menu in the location bar.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: