Skip to content

Commit

Permalink
Fixed mouse focus for touch events on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 20, 2019
1 parent 4bd8083 commit 582a3c9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/video/uikit/SDL_uikitwindow.m
Expand Up @@ -160,12 +160,6 @@ - (void)layoutSubviews
* heirarchy. */
[view setSDLWindow:window];

/* Make this window the current mouse focus for touch input */
if (displaydata.uiscreen == [UIScreen mainScreen]) {
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
}

return 0;
}

Expand Down Expand Up @@ -255,6 +249,14 @@ - (void)layoutSubviews
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
[data.uiwindow makeKeyAndVisible];

/* Make this window the current mouse focus for touch input */
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *) display->driverdata;
if (displaydata.uiscreen == [UIScreen mainScreen]) {
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
}
}
}

Expand Down

0 comments on commit 582a3c9

Please sign in to comment.