ecj2 / momo

[NOT MAINTAINED / ABANDONED] A simple 2D game-making library written in JavaScript.
MIT License
1 stars 0 forks source link

The mouse prevents iframes from receiving focus #7

Closed ecj2 closed 6 years ago

ecj2 commented 6 years ago

If a game installs the mouse and is played from within an iframe, clicking on the iframe does not set focus to the canvas, thus preventing keyboard inputs from working. However, if the mouse is not installed, clicking on the iframe does set focus to the canvas, and things work as expected.

ecj2 commented 6 years ago

I believe event.preventDefault() being called from withing Momo.manageMouseEvents() is the culprit here. The default for clicking within a frame is to set focus to said frame, but because the default event is being prevented across all mouse events, focus is never set. I think I can fix this by not calling event.preventDefault() if the event is not related to one of the mouse buttons.