emscripten-ports / SDL2

Other
166 stars 64 forks source link

Why emscripten_set_mouseup_callback use EMSCRIPTEN_EVENT_TARGET_DOCUMENT as traget #137

Open LionKenedi95 opened 3 years ago

LionKenedi95 commented 3 years ago

Hello.

Can you tell me why emscripten_set_mouseup_callback uses document as target, when emscripten_set_mousedown_callback takes data-> canvas_id as target. This may be a mistake.

In my case, this solution breaks the standard input behavior on the page, which is very strange.

Thanks in advance for your reply and sorry for my english :)

Daft-Freak commented 3 years ago

It does that to handle pressing inside the canvas, moving outside of it then releasing. SDL expects to still get the mouse up event in that case. (https://github.com/emscripten-ports/SDL2/commit/b1060d944f6fa379494f5f221cdbd370505fa687)

It should only prevent the default action if the mouse was inside though... (https://github.com/emscripten-ports/SDL2/commit/ed82ab12287937ac09eb41f1b979c068966fed2a)