cheerpj-meta icon indicating copy to clipboard operation
cheerpj-meta copied to clipboard

Control-click on Mac not triggering JPopupMenu

Open jkboyce opened this issue 5 years ago • 3 comments

On Mac, the popup menus in my app do not invoke with the usual control key+left click combo. (If you press the "Juggle" button, in the animation window that pops up there is a JPopupMenu in the area to the right.) A workaround is to use a two-button mouse, or enable "secondary click" in trackpad preferences. Still, this isn't an ideal user experience since the control+left click combo is supported by popular web apps (Google Drive for example), and all regular Mac applications (including Java ones).

I confirmed that java.awt.event.MouseEvent.isPopupTrigger() always returns false for the control+click combo on the Mac when running in CheerpJ, in both Chrome and Safari.

jkboyce avatar Apr 07 '20 21:04 jkboyce

We will consider fixing this the next time we iterate on mouse handling code, thanks for reporting this.

alexp-sssup avatar Apr 10 '20 14:04 alexp-sssup

:thumbsup: Update: I discovered that control+left click does work correctly in Firefox. So this issue is specific to Chrome and Safari.

jkboyce avatar Apr 10 '20 19:04 jkboyce

This issue is still present in CheerpJ 3.0.

Seems this is a result of the following MouseEvent.ctrlKey behaviour on macOS:

a click combined with the control key is intercepted by the operating system and used to open a context menu, so ctrlKey is not detectable on click events. source: MDN

JSFiddle reproduction:

  • On Chrome, ctrl+leftclick does not bring up the popup menu (incorrect)
  • On Firefore, ctrl+leftclick does bring up the popup menu (correct)
  • Regardless of browser, rightclick brings up the popup menu (correct)
  • e.isPopupTrigger() appears to always be true (not sure if correct)

I think the reason for this difference is that the behaviour described on MDN doesn't seem to apply to Firefox. Here's a JSFiddle test; on Chrome ctrl+leftclick gives ctrlKey: false but on Firefox ctrl+leftclick gives ctrlKey: true!

bates64 avatar Jan 26 '24 11:01 bates64