Emscripten: Partially fixed not removing key event callbacks if hint was used.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 06 Mar 2015 21:26:37 +0100
changeset 93774c29dc2baaa8
parent 9376 0495816fec54
child 9378 71743b696c06
Emscripten: Partially fixed not removing key event callbacks if hint was used.

The key event callbacks were always removed from the same target although it is
possible to set them to different targets using the hint. This is only a partial
fix because it assumes that the hint is not changed to a different value later.
src/video/emscripten/SDL_emscriptenevents.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Mon Mar 02 21:36:45 2015 -0500
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Fri Mar 06 21:26:37 2015 +0100
     1.3 @@ -621,10 +621,15 @@
     1.4      emscripten_set_touchmove_callback("#canvas", NULL, 0, NULL);
     1.5      emscripten_set_touchcancel_callback("#canvas", NULL, 0, NULL);
     1.6  
     1.7 -    emscripten_set_keydown_callback("#window", NULL, 0, NULL);
     1.8 -    emscripten_set_keyup_callback("#window", NULL, 0, NULL);
     1.9 +    const char *target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
    1.10 +    if (!target) {
    1.11 +        target = "#window";
    1.12 +    }
    1.13  
    1.14 -    emscripten_set_keypress_callback("#window", NULL, 0, NULL);
    1.15 +    emscripten_set_keydown_callback(target, NULL, 0, NULL);
    1.16 +    emscripten_set_keyup_callback(target, NULL, 0, NULL);
    1.17 +
    1.18 +    emscripten_set_keypress_callback(target, NULL, 0, NULL);
    1.19  
    1.20      emscripten_set_fullscreenchange_callback("#document", NULL, 0, NULL);
    1.21