Fixed mouse focus for touch events on iOS
authorSam Lantinga <slouken@libsdl.org>
Mon, 20 May 2019 14:08:35 -0700
changeset 12744cbd7a9f0a05e
parent 12743 c653e9fa9ca9
child 12745 c82ce49419a5
Fixed mouse focus for touch events on iOS
src/video/uikit/SDL_uikitwindow.m
     1.1 --- a/src/video/uikit/SDL_uikitwindow.m	Mon May 20 00:41:18 2019 -0400
     1.2 +++ b/src/video/uikit/SDL_uikitwindow.m	Mon May 20 14:08:35 2019 -0700
     1.3 @@ -160,12 +160,6 @@
     1.4       * heirarchy. */
     1.5      [view setSDLWindow:window];
     1.6  
     1.7 -    /* Make this window the current mouse focus for touch input */
     1.8 -    if (displaydata.uiscreen == [UIScreen mainScreen]) {
     1.9 -        SDL_SetMouseFocus(window);
    1.10 -        SDL_SetKeyboardFocus(window);
    1.11 -    }
    1.12 -
    1.13      return 0;
    1.14  }
    1.15  
    1.16 @@ -255,6 +249,14 @@
    1.17      @autoreleasepool {
    1.18          SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
    1.19          [data.uiwindow makeKeyAndVisible];
    1.20 +
    1.21 +        /* Make this window the current mouse focus for touch input */
    1.22 +        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.23 +        SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *) display->driverdata;
    1.24 +        if (displaydata.uiscreen == [UIScreen mainScreen]) {
    1.25 +            SDL_SetMouseFocus(window);
    1.26 +            SDL_SetKeyboardFocus(window);
    1.27 +        }
    1.28      }
    1.29  }
    1.30