Fix mouse button edge cases#309
Merged
Merged
Conversation
Upon SDL_MOUSEBUTTONUP, WindowManager sends onPointerUp down the render chain only if no buttons are held down. This prevents onPointerUp from being passed if one is released while multiple buttons are held down. For instance, if left and right are held down together, and left is released while right remains down, no mouse-up event is sent for the left mouse button. Always send onPointerUp on any SDL_MOUSEBUTTONUP.
dirtymustache
added a commit
to dirtymustache/SeriousProton
that referenced
this pull request
Apr 2, 2026
Fix mouse button edge cases (daid#309)
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.
Fix two edge cases that can result in a mouse button being read as down when it's up:
Holding down multiple mouse buttons, then releasing one of them, doesn't fire onMouseUp because onMouseUp is sent only when no mouse buttons are held.
For example, clicking and holding left mouse button on radar to set a heading, then also clicking and holding right button followed by releasing the left mouse button, leaves the left mouse button stuck in down state until the right mouse button is also released and left mouse button is clicked again.
Always fire onMouseUp when a
SDL_MOUSEBUTTONUPevent is caught.Holding down a mouse button, then changing focus away from EE and then releasing it, doesn't capture the button being released and thus never fires onMouseUp, leaving the button stuck in down state.
For example in windowed mode, clicking and holding on Helms radar to set a heading and then alt-tabbing to another window results in the button becoming stuck in down state and perpetually dragging until the mouse is clicked outside of the radar.
Capture
SDL_WINDOWEVENT_FOCUS_LOSTevents if window focus is lost while any button is held, and clearmouse_button_down_maskand fireonPointerUpusing the last known mouse position.