I’m testing out using webview in ETO in Rhino8 and I keep crashing Rhino when using the ExecuteScript function inside of the DocumentLoading Event. I can successfully inject the JavaScript once and then Rhino crashes. Any help would be appreciated. Thanks.
using Eto.Drawing;
using Eto.Forms;
using System;
using Rhino;
namespace TestWebUI
{
public class EtoForm : Form
{
public WebView Wv { get; private set; }
public bool IndexLoaded = false;
string index;
public EtoForm()
{
this.ClientSize = new Size(600, 600);
Wv = new WebView();
Wv.DocumentLoading += E_DocumentLoading;
Wv.DocumentLoaded += E_DocumentLoaded;
Content = Wv;
}
private void E_DocumentLoaded(object sender, WebViewLoadedEventArgs e)
{
if (e.Uri.AbsolutePath == index) IndexLoaded = true;
}
public void SetWVUrl(string url)
{
index = url.Replace("\\", "/");
Wv.Url = new Uri(index);
}
private void E_DocumentLoading(object sender, WebViewLoadingEventArgs e)
{
if (e.Uri.Scheme == "myapp")
{
e.Cancel = true; // Cancel Any Other Navigation
var path = e.Uri.PathAndQuery;
RhinoApp.WriteLine(path);
// change the button text to the path with injected javascript
string js = $"document.getElementById('greetingsbutton').innerText = '{path}';";
Wv.ExecuteScript(js);
}
}
}
}