I’m trying to use the informal protocol didCreateJavaScriptContext defined in WebFrameLoadDelegate.
Do I need to create a binding project or is it possible to achieve this without one?
namespace XamsharpDesktop {
partial class MyFrameLoadDelegate : WebFrameLoadDelegate {
public override void FinishedLoad(WebView sender, WebFrame forFrame) {
Console.WriteLine("FinishedLoad");
}
[Export("webView:didCreateJavaScriptContext:contextForFrame:")]
public void DidCreateJavascriptContext(WebView webView, JSContext jsContext, WebFrame forFrame) {
Console.WriteLine("DidCreateJavaScriptContext");
}
}
}
Xamarin support pointed in the direction of the CategoryAttribute and Registar documentation. After reading those and the source of MonoMacWebkit I tried to create a WebFrameLoadDelegateExtentions Interface or Category in the same project as my app but I wasn't able to get them working.
namespace XamsharpDesktop {
[Protocol]
partial interface WebFrameLoadDelegateExtensions {
[Export ("webView:didCreateJavaScriptContext:contextForFrame:")]
void DidCreateJavascriptContext(WebView webView, JSContext jsContext, WebFrame forFrame);
}
// [Category (typeof (WebFrameLoadDelegate))]
// public static class WebFrameLoadDelegateExtensions {
// [Export ("webView:didCreateJavaScriptContext:contextForFrame:")]
// static void DidCreateJavascriptContext(this WebFrameLoadDelegate self, WebView webView, JSContext jsContext, WebFrame forFrame) {
// Console.WriteLine("Extension DidCreateJavaScriptContext");
// }
// }
}
I attempted to start a binding project in Xamarin Studio but the only option was to create iOS binding project and I wasn't able to figure out how to use MonoMac.WebKit and MonoMac.ObjCRuntime from within the project. Is it possible to re-configure the iOS binding project to target Mac?