Skip to content

Instantly share code, notes, and snippets.

@prabindh
Last active December 13, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prabindh/524ddd79ae6c9815a97c8d43239bb9f5 to your computer and use it in GitHub Desktop.
Save prabindh/524ddd79ae6c9815a97c8d43239bb9f5 to your computer and use it in GitHub Desktop.
JsDialogHandler crash on Prompt dialog and callback continue
public class JsDialogHandler : IJsDialogHandler
{
string result = "default";
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl,
CefJsDialogType dialogType, string messageText, string defaultPromptText,
IJsDialogCallback callback, ref bool suppressMessage)
{
suppressMessage = true;
if (dialogType == CefJsDialogType.Prompt)
{
parent.Invoke(new Action(() =>
{
result = ShowTextInputForm(); // Show a form and get text input
}));
if(null != callback && !callback.IsDisposed)
{
callback.Continue(true, result);
}
}
else
{
MessageBox.Show(messageText, "Status", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
return true;
}
// Rest of class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment