emscripten: Let SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT accept "#none"
This is used to say "don't even try to listen for keypresses," for apps that are managing this outside of SDL. Fixes #10292.
This commit is contained in:
@@ -730,7 +730,7 @@ extern "C" {
|
|||||||
* - "#document": the javascript document object
|
* - "#document": the javascript document object
|
||||||
* - "#screen": the javascript window.screen object
|
* - "#screen": the javascript window.screen object
|
||||||
* - "#canvas": the WebGL canvas element
|
* - "#canvas": the WebGL canvas element
|
||||||
* - "": Don't bind anything at all
|
* - "#none": Don't bind anything at all
|
||||||
* - any other string without a leading # sign applies to the element on the
|
* - any other string without a leading # sign applies to the element on the
|
||||||
* page with that ID.
|
* page with that ID.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1029,11 +1029,11 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data)
|
|||||||
|
|
||||||
// Keyboard events are awkward
|
// Keyboard events are awkward
|
||||||
keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
||||||
if (!keyElement) {
|
if (!keyElement || !*keyElement) {
|
||||||
keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW;
|
keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*keyElement) {
|
if (SDL_strcmp(keyElement, "#none") != 0) {
|
||||||
emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
|
emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
|
||||||
emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
|
emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
|
||||||
emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
|
emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
|
||||||
|
|||||||
Reference in New Issue
Block a user