Forum > Cocoa
Minimum code for implementing WebView (deprecated) or WKWebView
trev:
--- Quote from: MISV on January 15, 2022, 11:20:35 am ---I am going to solve this "broken forwards of all kinds not working in my Lazarus" + "circular referencing" problems by...
Simply leaving out those declarations. I think that will work as long as I do not need to call them. At least I can compile then. Will need to see if causes problems runtime.
--- End quote ---
I've done this for other reasons and there've been no obvious issues. Nothing ventured, nothing gained :)
MISV:
Thank you :)
As everyone probably realizes, I am trying to hack and slash my way forward through the problems.
Seems Lazarus does not like this construct:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- TmsWKWebViewCore = objcclass external(WKWebView) public { available in macos 10.11, ios 9.0 } procedure setCustomUserAgent(newValue: NSString); message 'setCustomUserAgent:'; function customUserAgent: NSString; message 'customUserAgent'; end; TmsWKWebView = objcclass(TmsWKWebViewCore, WKScriptMessageHandlerProtocol) public procedure userContentController_didReceiveScriptMessage(userContentController: WKUserContentController; message_: WKScriptMessage); end;
(gives a bunch of error linker errors objc_class)
However using
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- // while we use setNavigationDelegate, that solution is not possible with *WKScriptMessageHandlerProtocol* and need to implemented in main class TmsWKWebView = objcclass(TmsWKWebViewCore, WKScriptMessageHandlerProtocol) public { available in macos 10.11, ios 9.0 } procedure setCustomUserAgent(newValue: NSString); message 'setCustomUserAgent:'; function customUserAgent: NSString; message 'customUserAgent'; public procedure userContentController_didReceiveScriptMessage(userContentController: WKUserContentController; message_: WKScriptMessage); end;
also causes problems since compiler then expects the UserAgent functions to be implemented and not externally bound.
MISV:
Anyone has any news regarding WKWebView? Just returning to look into this yet again. Has WKWebView declarations beend merged into fpc/widgetset cocoa support?
Navigation
[0] Message Index
[*] Previous page