[iOS DAC] Fix touch events getting from SDL2 to source2.
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Mar 2019 14:45:04 -0700
changeset 12626c8dae6bd7ce5
parent 12625 e58468e48179
child 12627 cbc9429a8b31
[iOS DAC] Fix touch events getting from SDL2 to source2.
src/video/uikit/SDL_uikitview.m
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Tue Mar 12 14:44:25 2019 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Tue Mar 12 14:45:04 2019 -0700
     1.3 @@ -82,6 +82,27 @@
     1.4      return self;
     1.5  }
     1.6  
     1.7 +- (void)layoutSubviews
     1.8 +{
     1.9 +	// Fix for touch ios.
    1.10 +#if TARGET_OS_IOS
    1.11 +	// on ios, a metal view gets added to our parent, and covers this for touch events.
    1.12 +	// So set ourselves to user interact, and siblings false. johna
    1.13 +	NSArray<UIView*>* subviews = [self.superview subviews];
    1.14 +	for (int i=0; i<[subviews count]; i++)
    1.15 +	{
    1.16 +		UIView *view = [subviews objectAtIndex:i];
    1.17 +		if (view == self) {
    1.18 +			[view setUserInteractionEnabled:YES];  // set our user interaction to true.
    1.19 +		} else {
    1.20 +			[view setUserInteractionEnabled:NO];  // siblings to false.
    1.21 +		}
    1.22 +	}
    1.23 +#endif
    1.24 +    [super layoutSubviews];
    1.25 +}
    1.26 +
    1.27 +
    1.28  - (void)setSDLWindow:(SDL_Window *)window
    1.29  {
    1.30      SDL_WindowData *data = nil;