public void RunJavaScriptTextInputPanel (WebKit.WKWebView webView, string prompt, string defaultText, WebKit.WKFrameInfo frame, System.Action<string> completionHandler) { // Create a native UIAlertController with the message var alertController = UIAlertController.Create (null, prompt, UIAlertControllerStyle.Alert); // Add a text field to the alert, set the placeholder text and keep a refernce to the field UITextField alertTextField = null; alertController.AddTextField ((textField) => { textField.Placeholder = defaultText; alertTextField = textField; }); // Pass the text to the completion handler when the "OK" button is tapped alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, okAction => { completionHandler (alertTextField.Text); })); // If "Cancel" is tapped, we can just return null alertController.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Default, cancelAction => { completionHandler (null); })); // Present the alert PresentViewController (alertController, true, null); }
public void RunJavaScriptAlertPanel (WebKit.WKWebView webView, string message, WebKit.WKFrameInfo frame, System.Action completionHandler) { // Create and present a native UIAlertController with the message var alertController = UIAlertController.Create (null, message, UIAlertControllerStyle.Alert); alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, null)); PresentViewController (alertController, true, null); // Call the completion handler completionHandler (); }
public void StartedProvisionalLoad(WebKit.WebView sender, WebKit.WebFrame forFrame) { var url = sender.MainFrameUrl; if (!Authenticator.HasCompleted) { Uri uri; if (Uri.TryCreate (url, UriKind.Absolute, out uri)) { if (Authenticator.CheckUrl (uri, GetCookies (url))) return; } } }
void CustomContextMenuManager_ShowContextMenu(object sender, WebKit.ShowContextMenuEventArgs e) { // Here we handle our custom menu implementation. // Remember that firstly we have set Browser.UseDefaultContextMenu = false // Otherwise this event will not be fired and the default webkit context // menu will be shown. ContextMenu Menu; if (e.MenuType == WebKit.ContextMenuType.Image) Menu = imageContextMenu; else if (e.MenuType == WebKit.ContextMenuType.ImageAndLink) Menu = imageAndLinkContextMenu; else if (e.MenuType == WebKit.ContextMenuType.Link) Menu = linkContextMenu; else if (e.MenuType == WebKit.ContextMenuType.Input) Menu = inputContextMenu; else if (e.MenuType == WebKit.ContextMenuType.Form) Menu = formContextMenu; else Menu = normalContextMenu; Menu.Show((sender as WebKitBrowser), e.Location); }
private void WebViewNavigationRequested(object o, WebKit.NavigationRequestedArgs args) { Controller.LinkClicked (args.Request.Uri); // Don't follow HREFs (as this would cause a page refresh) if (!args.Request.Uri.Equals ("file:")) args.RetVal = 1; }
public void WillPerformClientRedirect(WebKit.WebView sender, Foundation.NSUrl toUrl, double secondsDelay, Foundation.NSDate fireDate, WebKit.WebFrame forFrame) { var url = sender.MainFrameUrl; if (!Authenticator.HasCompleted) { Uri uri; if (Uri.TryCreate(url, UriKind.Absolute, out uri)) { if (Authenticator.CheckUrl(uri, GetCookies(url))) { forFrame.StopLoading(); return; } } } else { forFrame.StopLoading(); } }
/// <summary> /// Handles changes in the <title> tag of the WebView /// </summary> /// <description> /// Waits for changes in the title and passes them for processing and deserialization /// to the message manager. This method is the link between the designer surface and the /// C# backend of the designer. /// </description> void WebView_OnTitleChanged (object o, WebKit.TitleChangedArgs args) { try { msgManager.HandleMessage (args.Title); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine (ex.ToString ()); } }
private void webKitBrowser1_StatusTextChanged(object sender, WebKit.WebKitBrowserStatusChangedEventArgs e) { if (sender.Equals(webKitBrowser1)) statusLabel.Text = e.StatusText; // link hovering status text is only supported in nightly builds }
private void webKitBrowser1_ShowJavaScriptPromptPanel(object sender, WebKit.ShowJavaScriptPromptPanelEventArgs e) { e.ReturnValue = Microsoft.VisualBasic.Interaction.InputBox(e.Message, "", e.DefaultValue); }
private void webKitBrowser1_ShowJavaScriptConfirmPanel(object sender, WebKit.ShowJavaScriptConfirmPanelEventArgs e) { bool val = (MessageBox.Show(e.Message,"OpenWebKitSharp Example",MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK); e.ReturnValue = val; }
private void webKitBrowser1_ShowJavaScriptAlertPanel(object sender, WebKit.ShowJavaScriptAlertPanelEventArgs e) { MessageBox.Show(e.Message); }
private void webKitBrowser1_ProgressChanged(object sender, WebKit.ProgressChangesEventArgs e) { toolStripProgressBar1.Value = e.Percent; }
private void webKitBrowser1_NewWindowCreated(object sender, WebKit.NewWindowCreatedEventArgs e) { AddTab(e.WebKitBrowser); }
private void webKitBrowser1_FormSubmit(object sender, WebKit.FormDelegateFormEventArgs e) { //e.Listener.continueSubmit(); from 1.5 Beta 2 this is automatically called }
private void webKitBrowser1_FaviconAvaiable(object sender, WebKit.FaviconAvailableEventArgs e) { if (e.Favicon != null) { fav.Visible = true; fav.Image = e.Favicon.ToBitmap(); } else fav.Visible = false; }