Skip to content

Fix macOS multi-click by setting CGEvent click state#949

Open
PekingSpades wants to merge 1 commit intoasweigart:masterfrom
PekingSpades:bugfix-macos-desktop-drag
Open

Fix macOS multi-click by setting CGEvent click state#949
PekingSpades wants to merge 1 commit intoasweigart:masterfrom
PekingSpades:bugfix-macos-desktop-drag

Conversation

@PekingSpades
Copy link
Copy Markdown

Summary

  • On macOS, multi-clicks were sent as repeated single clicks, which some UI targets treat as separate clicks.
  • This change sets kCGMouseEventClickState per down/up event so the OS recognizes double/triple clicks.
  • click(clicks=N) on macOS now routes through a single _multiClick call to preserve click state sequencing.

Behavior change

  • macOS multi-click now uses the correct click state on each event.
  • This aligns doubleClick()/tripleClick() behavior with native expectations (e.g., desktop icon activation, multi-click selection in editors).

Regression notes

  • Potential risk: Some apps that previously responded to repeated single clicks might now treat them as a true multi-click (double/triple) and behave differently.
  • We still emit the same number of down/up events; only the click state metadata changes.

Test plan

  • Double-click a desktop icon: should open as expected.
  • Double-click in a text editor: should select word.
  • Triple-click in a text editor: should select paragraph.

Related open issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant