Forum Xamarin.Mac

Having issues with RunJavaScriptConfirmPanel method inside WKUIDelegate class

Hi there,

I am new to Mac OSX development using Xamarin and am currently trying to build an app on Mac OSX using WKWebView to load a HTML on it.

Basically what is happening is, when a user clicks on a button we are trying to display a confirmation panel with Javascript (function inside the loaded HTML) asking them whether they want to proceed or not. We got everything working up until this part, however, when the user clicks on either of the "OK" or the "Cancel" button, the app freezes and I cannot click on anything.

I have already gone ahead and set the UIDelegate of the WKWebView.

What I currently have inside the WKUIDelegate class:

public override void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler)
{
NSAlert alert = new NSAlert();
alert.InformativeText = "Are you sure you want to delete this item?";
alert.AddButton("OK");
alert.AddButton("Cancel");
alert.RunModal();
}

Any help would be appreciated, thank you in advance.

Answers

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    I've never used that class, but there is an iOS sample that uses a similar API, which might be useful to look at.

Sign In or Register to comment.