Skip to content

Fix lost MouseButtonUp events when cursor leaves canvas (Web/WASM)#602

Open
TheRedDeveloper wants to merge 1 commit intonot-fl3:masterfrom
TheRedDeveloper:releaseoutsidecanvasfix
Open

Fix lost MouseButtonUp events when cursor leaves canvas (Web/WASM)#602
TheRedDeveloper wants to merge 1 commit intonot-fl3:masterfrom
TheRedDeveloper:releaseoutsidecanvasfix

Conversation

@TheRedDeveloper
Copy link

Problem:

In the WASM target, the mouse event listener for mouseup was attached directly to the canvas element (canvas.onmouseup).

If a user clicks inside the canvas, drags the mouse outside the canvas boundaries, and then releases the button, the canvas element does not receive the event. This causes the application to miss the MouseButtonUp event and think the mouse is still held down.

Solution:

Changed the event binding in gl.js to listen for mouseup on the global window object instead of the canvas. This ensures the release event is caught regardless of where the cursor is (on and off the page).

Yes, this is the same issue as the one in the PR on macroquad, except this one is a web issue.

Hope this can get merged soon.

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