diff --git a/p5.js-screen-saver/p5_js_screen_saverView.m b/p5.js-screen-saver/p5_js_screen_saverView.m index 2307e06..ed0226c 100644 --- a/p5.js-screen-saver/p5_js_screen_saverView.m +++ b/p5.js-screen-saver/p5_js_screen_saverView.m @@ -24,10 +24,10 @@ - (instancetype)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview NSURL *url = [NSURL URLWithString:URLString]; // add webview - WebView *webView = [[WebView alloc] initWithFrame:frame]; - webView.frameLoadDelegate = self; + WKWebView *webView = [[WKWebView alloc] initWithFrame:[self bounds]]; + webView.navigationDelegate = self; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; - [webView.mainFrame loadRequest:request]; + [webView loadRequest:request]; [self addSubview:webView]; return self; } @@ -62,4 +62,26 @@ - (NSWindow*)configureSheet return nil; } +// Override default listeners + +- (NSView *)hitTest:(NSPoint)aPoint { + return self; +} + +- (void)keyDown:(NSEvent *)theEvent { + return; +} + +- (void)keyUp:(NSEvent *)theEvent { + return; +} + +- (BOOL)acceptsFirstResponder { + return YES; +} + +- (BOOL)resignFirstResponder { + return NO; +} + @end