Recent

Author Topic: Minimum code for implementing WebView (deprecated) or WKWebView  (Read 42903 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Minimum code for implementing WebView (deprecated) or WKWebView
« Reply #60 on: January 15, 2022, 10:22:46 pm »
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.

I've done this for other reasons and there've been no obvious issues. Nothing ventured, nothing gained :)

MISV

  • Hero Member
  • *****
  • Posts: 792
Re: Minimum code for implementing WebView (deprecated) or WKWebView
« Reply #61 on: January 17, 2022, 01:22:59 pm »
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  [Select][+][-]
  1.   TmsWKWebViewCore = objcclass external(WKWebView)
  2.   public
  3.     { available in macos 10.11, ios 9.0 }
  4.     procedure setCustomUserAgent(newValue: NSString); message 'setCustomUserAgent:';
  5.     function customUserAgent: NSString; message 'customUserAgent';
  6.   end;
  7.   TmsWKWebView = objcclass(TmsWKWebViewCore, WKScriptMessageHandlerProtocol)
  8.   public
  9.     procedure userContentController_didReceiveScriptMessage(userContentController: WKUserContentController; message_: WKScriptMessage);
  10.   end;
  11.  

(gives a bunch of error linker errors objc_class)


However using


Code: Pascal  [Select][+][-]
  1.  
  2. // while we use setNavigationDelegate, that solution is not possible with *WKScriptMessageHandlerProtocol* and need to implemented in main class
  3. TmsWKWebView = objcclass(TmsWKWebViewCore, WKScriptMessageHandlerProtocol)
  4.   public
  5.     { available in macos 10.11, ios 9.0 }
  6.     procedure setCustomUserAgent(newValue: NSString); message 'setCustomUserAgent:';
  7.     function customUserAgent: NSString; message 'customUserAgent';
  8.   public
  9.     procedure userContentController_didReceiveScriptMessage(userContentController: WKUserContentController; message_: WKScriptMessage);
  10.   end;
  11.  


also causes problems since compiler then expects the UserAgent functions to be implemented and not externally bound.


MISV

  • Hero Member
  • *****
  • Posts: 792
Re: Minimum code for implementing WebView (deprecated) or WKWebView
« Reply #62 on: April 16, 2024, 11:37:54 am »
Anyone has any news regarding WKWebView? Just returning to look into this yet again. Has WKWebView declarations beend merged into fpc/widgetset cocoa support?

 

TinyPortal © 2005-2018