From 82758efc46cf015b09a118dcc74a017e88ec6e56 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 12 Mar 2019 14:45:04 -0700 Subject: [PATCH] [iOS DAC] Fix touch events getting from SDL2 to source2. --- src/video/uikit/SDL_uikitview.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 25a0d5f26..d1f72d06f 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -82,6 +82,27 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; return self; } +- (void)layoutSubviews +{ + // Fix for touch ios. +#if TARGET_OS_IOS + // on ios, a metal view gets added to our parent, and covers this for touch events. + // So set ourselves to user interact, and siblings false. johna + NSArray* subviews = [self.superview subviews]; + for (int i=0; i<[subviews count]; i++) + { + UIView *view = [subviews objectAtIndex:i]; + if (view == self) { + [view setUserInteractionEnabled:YES]; // set our user interaction to true. + } else { + [view setUserInteractionEnabled:NO]; // siblings to false. + } + } +#endif + [super layoutSubviews]; +} + + - (void)setSDLWindow:(SDL_Window *)window { SDL_WindowData *data = nil;