Implement common web message identifier for macOS

This commit is contained in:
Tobias Taschner
2021-02-28 19:57:33 +01:00
parent a27f73367c
commit 2c3d179923

View File

@@ -398,6 +398,11 @@ bool wxWebViewWebKit::AddScriptMessageHandler(const wxString& name)
{
[m_webView.configuration.userContentController addScriptMessageHandler:
[[WebViewScriptMessageHandler alloc] initWithWxWindow:this] name:wxCFStringRef(name).AsNSString()];
// Make webkit message handler available under common name
wxString js = wxString::Format("window.%s = window.webkit.messageHandlers.%s;",
name, name);
AddUserScript(js);
RunScript(js);
return true;
}