Fix double click never firing on emscripten - #185
Merged
Conversation
Keep the native fetch handle so cancellation and deadlines can stop the request. Mark the request complete before closing it because Emscripten calls the error callback during an in-flight close.
Focus and resize events can arrive while Asyncify has suspended onFrame. Queue those callbacks until onFrame returns so window state changes at a frame boundary.
processFlagsChanged toggled each modifier key per event, so any edge delivered while the window was not key (focus stolen mid-chord, Cmd-Tab entry, activation settling during launch) latched an inverted modifier for the rest of the session. Every unmodified key chord then resolved with a phantom SHIFT/CTRL/ALT attached, silently retargeting exact-match consumers. Shift/Control/Option/Command now derive up/down from the absolute NSEventModifierFlags state (class bit plus IOKit device bits for the left/right split), so a missed edge self-corrects on the next flagsChanged. windowDidBecomeKey seeds the same absolute state after clearing buttons, so a modifier held across focus gain cannot register its release as a phantom press. CapsLock keeps toggle semantics. Also register the NSWindow key-eligibility override with its real zero-argument selector: 'canBecomeKeyWindow:' (with colon) never overrode the getter, leaving borderless windows unable to become key.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shared multi click logic in internal.nim compares the time between clicks against platformDoubleClickInterval, which each platform sets at init: macOS from NSEvent.doubleClickInterval, win32 from GetDoubleClickTime(). The emscripten platform never set it, so it stayed 0.0 and the check
doubleClickInterval <= platformDoubleClickIntervalcould never pass. DoubleClick, TripleClick and QuadrupleClick simply never fired in browser builds.Browsers do not expose the user's double click speed, so this sets the common 500 ms default at init.
Verified in a WebGL2 emscripten build (windy + boxy game): double click events now arrive.
Note: the linux X11 platform also does not appear to set platformDoubleClickInterval, so it likely has the same bug and could use the same treatment.
🤖 Generated with Claude Code