FlatLaf icon indicating copy to clipboard operation
FlatLaf copied to clipboard

Idea: Avoid triggering popup menu action from mouse-release shortly after mouse-press

Open eirikbakke opened this issue 1 year ago • 2 comments

On Windows, popup menus appear when releasing the right-click button. On MacOS, they appear when pressing the right-click button. FlatLAF correctly follows this behavior on each platform.

There's a usability problem on MacOS, though. If the user moves the cursor towards the intended menu item, and happens to release the mouse button while the cursor is now over another menu item, then the latter action will be executed instead of the intended one. I make this mistake myself quite often when working quickly (with an external mouse, not a trackpad). See the screen recording below:

https://youtube.com/shorts/RzlnnRMP8J8

Proposal: In a JMenuItem, ignore a right-button mouse-release event for action triggering purposes if it comes within a short duration of the corresponding mouse-press event (e.g. 250ms).

eirikbakke avatar Jan 27 '25 03:01 eirikbakke

But isn't this a general "problem" when using right-mouse-press-hold-and-move-and-release on macOS. This can also happen in any native macOS app, right?

Proposal: In a JMenuItem, ignore a right-button mouse-release event for action triggering purposes if it comes within a short duration of the corresponding mouse-press event (e.g. 250ms).

Not sure whether this would help 😕 I mean you can accidentally release the mouse button also after the 250ms...

DevCharly avatar Feb 10 '25 22:02 DevCharly

This can also happen in any native macOS app, right?

Yes, correct! This would be an improvement over MacOS defaults. Just a bonus feature, so to speak. (I considered implementing it myself and submitting a PR, but thought I'd solicit your opinion.)

I mean you can accidentally release the mouse button also after the 250ms...

There's a certain threshold of time before which it is reasonable to assume that the user is trying to click, rather than drag. Above that threshold, it is reasonable to assume the user is trying to drag.

eirikbakke avatar Feb 10 '25 22:02 eirikbakke