Created
July 31, 2017 20:33
-
-
Save chamons/cb0da51a4c649f9693cff01b7d7fed3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using AppKit; | |
using Foundation; | |
using WebKit; | |
namespace webViewTest | |
{ | |
public partial class ViewController : NSViewController, IWebFrameLoadDelegate | |
{ | |
public ViewController(IntPtr handle) : base(handle) | |
{ | |
} | |
[Export ("webView:didClearWindowObject:forFrame:")] | |
public void ClearedWindowObject (WebView webView, WebScriptObject windowObject, WebFrame forFrame) | |
{ | |
this.someWebView.WindowScriptObject.SetValueForKey (this, new NSString ("ViewController")); | |
InvokeOnMainThread (() => | |
{ | |
this.someLable.StringValue = "ClearedWindowObject is called"; | |
}); | |
} | |
public override void ViewDidLoad() | |
{ | |
base.ViewDidLoad(); | |
var uri = Uri.EscapeUriString(Path.Combine(NSBundle.MainBundle.ResourcePath, "index.html")); | |
this.someWebView.FrameLoadDelegate = this;z | |
this.someLable.StringValue = "ClearedWindowObject is NOT called"; | |
this.someWebView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl(uri))); | |
// Do any additional setup after loading the view. | |
} | |
public override NSObject RepresentedObject | |
{ | |
get | |
{ | |
return base.RepresentedObject; | |
} | |
set | |
{ | |
base.RepresentedObject = value; | |
// Update the view, if already loaded. | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment