Skip to content

Commit

Permalink
Changed from WebView to WKWebView (better performance); Added overrid…
Browse files Browse the repository at this point in the history
…e of default event listeners
  • Loading branch information
jnsdbr committed Oct 8, 2018
1 parent b1764ce commit 70040e1
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions p5.js-screen-saver/p5_js_screen_saverView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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

0 comments on commit 70040e1

Please sign in to comment.