Answer the question
In order to leave comments, you need to log in
How to fix CefSharp (new tabs) error?
I make my browser (no bells and whistles), the only condition is to open links in a new tab.
I asked a question on the cefsharp general forum - they sent it to the link: , there are a lot of examples - I tried to compile, a lot of errors and other things. I went the other way: I found the source code of SharpBrowser - unpacked the bin folder, there is a fully working project and it has an implementation of opening a link in a new tab.
The file is called: ContextMenuHandlers.cs
private const int OpenLinkInNewTab = 26507;
......
//Removing existing menu item
//bool removed = model.Remove(CefMenuCommand.ViewSource); // Remove "View Source" option
if (parameters.LinkUrl != "") {
model.AddItem((CefMenuCommand)OpenLinkInNewTab, "Open link in new tab");
model.AddItem((CefMenuCommand)CopyLinkAddress, "Copy link");
model.AddSeparator();
}
......
public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) {
if (id == OpenLinkInNewTab) {
ChromiumWebBrowser newBrowser = myForm.AddNewBrowserTab(parameters.LinkUrl, false, browser.MainFrame.Url);
}}
Severity Code Description Project File Line Suppression State
Error CS1061 'Form1' does not contain a definition for 'AddNewBrowserTab' and no accessible extension method 'AddNewBrowserTab' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?) AGO h:\РАЗЛИЧНЫЕ ПРОЕКТЫ\C#\MyCustomMenuHandler.cs 72 Active
// React to the first ID (show dev tools method)
if (commandId == (CefMenuCommand)26501)
{
browser.GetHost().ShowDevTools();
return true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question