When calling emscripten_set_main_loop on a SDL aplication, all HTML inputs (like text inputs) have the keyboard interaction locked. I see that I can continue interacting with the page, and with other controls using the mouse, and even keyboard events in the page are caught, but is like the inputs all become readonly.
Although I can't find anything int the documentation regarding this behaviour, this kinda makes sense, as SDL will take over the keyboard. But I would expect that emscripten_cancel_main_loop would return the control to the inputs. However, this is not the case, and the only way to return control to the inputs is by reloading the page.
I tested both in Firefox and Chrome.
Is this expected behvaiour? If so, how can I get the keyboard control back?
We don't currently have a mechanism for this, but we probably should. Many applications just take over the whole page, so the default is usually ok, but there are definitely cases otherwise.
A good starting point is to design an API for this. Tying it to the main loop is an interesting idea, and seems like it could help many use cases, but in general it isn't accurate enough I think. Perhaps we need an explicit API, but I don't have an idea currently for what.
I face the same issue, Unfortunately, several other similar questions #7043 #4106 #2668 They're all closed.
This is a OK solution for me. I just hope that I can temporarily stop receiving events at a specific time and resume receiving events after finishing the work I need
void setEventEnable(int v) {
int state = v ? SDL_ENABLE : SDL_DISABLE;
SDL_EventState(SDL_TEXTINPUT, state);
SDL_EventState(SDL_KEYDOWN, state);
SDL_EventState(SDL_KEYUP, state);
SDL_EventState(SDL_MOUSEMOTION, state);
SDL_EventState(SDL_MOUSEBUTTONDOWN, state);
SDL_EventState(SDL_MOUSEBUTTONUP, state);
}