From 3caf48b04c1329c6f33f39f11e9af261b7ac99c9 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Mon, 8 Mar 2021 10:12:00 +0100 Subject: [PATCH] macOS: Implement window.print() in wxWebView A WKUIDelegate method has to be implemented to make a javascript calling window.print() working. --- src/osx/webview_webkit.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 8dae40f8b8..1457ece981 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -933,6 +933,15 @@ WX_API_AVAILABLE_MACOS(10, 12) } #endif // __MAC_OS_X_VERSION_MAX_ALLOWED +// The following WKUIDelegateMethods are undocumented as of macOS SDK 11.0, +// but are documented in the WebKit cocoa interface headers: +// https://github.com/WebKit/WebKit/blob/main/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h + +- (void)_webView:(WKWebView *)webView printFrame:(WKFrameInfo*)frame +{ + webKitWindow->Print(); +} + @end @implementation WebViewScriptMessageHandler