/// <summary> /// When the user interacts with the context menu /// </summary> public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { // Custom Commands // //Copy link Address if ((int)commandId == Copy) { //Save the link into windows clipboard if (parameters.LinkUrl != "") { Clipboard.SetText(parameters.LinkUrl); } } if ((int)commandId == OpenInNewTab) { //Validates that the LinkURL isn't null if (parameters.LinkUrl == "") { return(false); } //Getting the TabControl MaterialTabControl basedTabControl = (MaterialTabControl)mainTabPage.Parent; //Creating a new Tab MaterialTabPage newTab = new Igloo.Control.Browser.IBrowser().getIBrowserTab(parameters.LinkUrl, basedTabControl.Size); //Inovke on UI thread if (basedTabControl.InvokeRequired) { basedTabControl.Invoke(new Action(() => { //Add the new TabPage to the TabControl and then selects it basedTabControl.TabPages.Add(newTab); basedTabControl.SelectTab(newTab); })); } } return(false); }
/// <summary> /// Used to show the popup of the browser in a new tab /// </summary> /// <param name="browserControl">The ChromiumWebBrowser control</param> /// <param name="browser">IBRowser control of the browser</param> /// <param name="frame">IFrame?</param> /// <param name="targetUrl">Target URL of the popup</param> /// <param name="targetFrameName">Frame of the target</param> /// <param name="targetDisposition"></param> /// <param name="userGesture">User movement</param> /// <param name="popupFeatures">Features of the popup (Currently not supported)</param> /// <param name="windowInfo">Window Info (name, etc)</param> /// <param name="browserSettings">Settings</param> /// <param name="noJavascriptAccess">Java Script Access</param> /// <param name="newBrowser">New browser window for the popup</param> /// <returns>Returns nothing to prevent a popup</returns> public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) { //Getting the TabControl MaterialTabControl basedTabControl = (MaterialTabControl)tabPage.Parent; //Creating a new Tab MaterialTabPage newTab = new Igloo.Control.Browser.IBrowser().getIBrowserTab(targetUrl, basedTabControl.Size); //Inovke on UI thread if (basedTabControl.InvokeRequired) { basedTabControl.Invoke(new Action(() => { //Add the new TabPage to the TabControl and then selects it basedTabControl.TabPages.Add(newTab); basedTabControl.SelectTab(newTab); })); } //Returns false newBrowser = null; return(true); }