Recent

Author Topic: Bug? Why is PROTOCOLS and other left undefined?  (Read 3711 times)

MISV

  • Hero Member
  • *****
  • Posts: 772
Bug? Why is PROTOCOLS and other left undefined?
« on: December 07, 2021, 11:27:19 pm »

WK_API_ENABLED, PROTOCOLS are left undefined it seems? It matters if using delegates, e.g. WKWebView

Inspecting WKNavigationDelegate.inc it appears all the important definitions for delegates are not getting compiled in because neither  WK_API_ENABLED nor PROTOCOLS are defined?

It is causing me headache since I can not get those things working. See this example:



So first I had

Code: Pascal  [Select][+][-]
  1.   Tmsdv_cocoanative_WebBrowserCocoaWKWebViewDelegate_Navigation = objcclass(NSObject)
  2.   private
  3.     FBrowserCtrlRef: TmsdvWebBrowserCocoaWKWebView;
  4.   public
  5.     // need implement
  6.   end;
  7.  
  8.       FDelegate_Cocoa_Navigation := Tmsdv_cocoanative_WebBrowserCocoaWKWebViewDelegate_Navigation.alloc.init;
  9.       FDelegate_Cocoa_Navigation.FBrowserCtrlRef := Self;
  10.       FWebView_CocoaWKWebView.setNavigationDelegate(FDelegate_Cocoa_Navigation);
  11.  
  12.  

This gives error

Quote
Error: Incompatible type for arg no. 1: Got "Tmsdv_cocoanative_WebBrowserCocoaWKWebViewDelegate_Navigation", expected "WKNavigationDelegateProtocol"

Now this seems like a great error and easy fix

Code: Pascal  [Select][+][-]
  1.   Tmsdv_cocoanative_WebBrowserCocoaWKWebViewDelegate_Navigation = objcclass(NSObject, WKNavigationDelegateProtocol)
  2.   private
  3.     FBrowserCtrlRef: TmsdvWebBrowserCocoaWKWebView;
  4.   public
  5.     // need implement
  6.   end;
  7.  

But this will throw another error

Quote
Error: Identifier not found "WKNavigationDelegateProtocol"

.... Now I have added all units I could think of, but it won't help and the reason seems to be:

fpcsrc/packages/cocoaint/src/webkit/WebKit.pas
includes
fpcsrc/packages/cocoaint/src/webkit/src/Sources.inc
includes
fpcsrc/packages/cocoaint/src/webkit/src/webkit/WKNavigationDelegate.inc

But in this unit the WKNavigationDelegateProtocol does not get compiled in because these are not defined "WK_API_ENABLED, PROTOCOLS"


I am trying to understand how Lazarus one place can recognize the type, but then not recognize the type if I use it. Anyhow, I tried a "hack" defining the beforementioned defines them and then *including* the *WKNavigationDelegate.inc* file myself, but, well I did not get it working.


« Last Edit: December 08, 2021, 02:04:51 am by MISV »


 

TinyPortal © 2005-2018