How can I ignore all touch events in WKWebView and its enclosingScrolllView

109 Views Asked by At

I have a WKWebView (discussed in this page - How can I paginate html in a wkwebview?) and I'm trying a different approach to solving the problem discussed there.

What I want to do is trap scroll events in the view for the entire window ([self.window.contentView setAllowedTouchTypes:(NSTouchTypeMaskDirect | NSTouchTypeMaskIndirect)];) and then ignore all touch events for WKWebView and WKWebView's enclosing scrollview.

I can see that my setAllowedTouchTypes is working as follows…

@interface NSView ( TouchEvents )

@end

@implementation NSView ( TouchEvents )

- (void)touchesBeganWithEvent:(NSEvent *)event {
    NSLog(@"Touched");    
}

@end

Even though I can see the 'touched' messages in the logs, the contents of my WKWebView still scrolls around when I swipe with my fingers. For this to work, I need it not to move at all!

Try as I might, I can't work out how to stop the swipes working for my WKWebView - and there doesn't seem to be anything in Interface Builder to achieve this aim either.

0

There are 0 best solutions below