Skip to content

Fix mouse button edge cases#309

Merged
daid merged 2 commits into
daid:masterfrom
oznogon:fix-mouse-button-edge-cases
Mar 27, 2026
Merged

Fix mouse button edge cases#309
daid merged 2 commits into
daid:masterfrom
oznogon:fix-mouse-button-edge-cases

Conversation

@oznogon

@oznogon oznogon commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

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_MOUSEBUTTONUP event 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_LOST events if window focus is lost while any button is held, and clear mouse_button_down_mask and fire onPointerUp using the last known mouse position.

oznogon added 2 commits March 26, 2026 18:06
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.
@daid
daid merged commit 0784949 into daid:master Mar 27, 2026
6 checks passed
@oznogon
oznogon deleted the fix-mouse-button-edge-cases branch March 27, 2026 20:30
dirtymustache added a commit to dirtymustache/SeriousProton that referenced this pull request Apr 2, 2026
Fix mouse button edge cases (daid#309)
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.

2 participants