The code works when you load a page but if you save the file path and read it from a prefs, the content is not loaded. I’m tried all solutions like adding file:/// . Blank page.
If the new release is not working, and they broke the workaround, see if you can aply for the 90-day money back guarantee. it is not fair to waste money in something that is not working. See if you can use the old HTMLViewer
This is the code I use for the DesktopHTMLViewer. Just tested in 2022r3.2 and it worked.
Private Sub GrantAccessToFolder(inFolder as FolderItem)
#if (TargetMacOS) AND (XojoVersion >= 2020.01) then
// copied from https://forum.xojo.com/t/new-problem-with-htmlviewer-loadpage-since-version-2020-r1/56514/7
// --- Originally created in July 2020. <--- Leave this info here so it's easier to track which version of the code.
// Published Sep 1st 2020.
// written by Sam Rowlands of Ohanaware.com
// Apple documentation for this API: https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl?language=objc
Declare Function NSClassFromString Lib "Foundation" (inClassName As CFStringRef) As Integer
Declare Function NSURLfileURLWithPathIsDirectory Lib "Foundation" Selector "fileURLWithPath:isDirectory:" (NSURLClass As Integer, path As CFStringRef, directory As Boolean) As Integer
Declare Function WKWebViewloadFileURL Lib "WebKit" Selector "loadFileURL:allowingReadAccessToURL:" (HTMLViewer As Ptr, URL As Integer, readAccessURL As Integer) As Integer
// --- Create a NSURL object from a Xojo Folderitem.
DIM folderURL As Integer = NSURLfileURLWithPathIsDirectory(NSClassFromString("NSURL"), inFolder.NativePath, inFolder.IsFolder)
// --- This bit is not technically correct. The first parameter after the instance should actually be the page that you're trying to load.
// But as we're not loading a page per say... For the purpose of just setting access rights, we ignore the return
// value as we don't need to display progress.
Call WKWebViewloadFileURL(me.Handle, folderURL, folderURL)
#EndIf
End Sub