Seeking WebViewMBS replacement

I’ve been using MBS’ WebViewMBS for displaying html code I provide directly (i.e. I do not want to display a website loaded from the internet).

But now, with Xojo 2021r3, that’s not available any more. MBS’s own documentation is not helping - it simply says it’s not available any more, but offers no help on how to substitute it.

I need this only on macOS, for iClip.

Which APIs are available, from Xojo or from MBS, that let me render a custom html string into a window view? Ideally, I’d also like to use the following features that I did before:

  1. Set prefs to turn off most advanced options:
dim prefs as WebPreferencesMBS = mWebView.preferences
prefs.arePlugInsEnabled = false
prefs.isJavaEnabled = false
prefs.isJavaScriptEnabled = false
prefs.allowsAnimatedImageLooping = false
prefs.allowsAnimatedImages = false
prefs.tabsToLinks = false
prefs.autosaves = false
prefs.cacheModel = WebPreferencesMBS.WebCacheModelDocumentViewer
  1. The rendered page should be able to use a transparent background so that I see the window’s background:
mWebView.DrawsBackground = false
  1. Scale the rendered view (for making a page fit into my window, avoiding scrollbars):
mWebView.mainFrame.frameView.documentView.superview.scaleUnitSquareToSize NSMakeSizeMBS (scale, scale)

You can still load html into WKWebViewControlMBS:

WKWebViewControlMBS1.LoadHTML(theHtml, "")

There preferences also mostly work:

dim thePrefs as new WKPreferencesMBS(me.WKWebView)
thePrefs.shouldPrintBackgrounds = True
thePrefs.javaScriptCanOpenWindowsAutomatically = False
1 Like

Oh, one more important requirement is that I need to be able to intercept any clicks on links, so that I can deny them. I.e, if the html page contains a clickable link, and if the user clicks on it, I do not want the page to load the linked URL!

Have you looked back at the built-in HTMLViewer recently? I’d guess that with some declares, you could accomplish all of your requirements now.

Greg, I haven’t. I am first looking for some alternatives that make the transition as easy as possible. Doing this all with declares is kind of painful, and I’m already investing more time into this iClip update than it’s worth the revenue, I’m afraid.

Well, WKWebViewControlMBS control has an event: decidePolicyForNavigationAction

There you can decide what to do with the action.

2 Likes