Table of Contents
Customizing Context Menu

If you use EO.Wpf.WebControl or EO.WinForms.WebControl, you can set the control's ContextMenu property directly to customize the control's context menu. Alternatively, you can also customize the context menu on the WebView class by handling the WebView's BeforeContextMenu event. The advantage of this approach is more context information such as the type of the element under the mouse cursor will be available.

The following code demonstrates this feature:

//Attach event handler
WebView1.BeforeContextMenu += new BeforeContextMenuHandler(WebView_BeforeContextMenu);

//Build a custom context menu in the event handler
void WebView_BeforeContextMenu(object sender, BeforeContextMenuEventArgs e)
{
e.Menu.Items.Clear();
e.Menu.Items.Add(new EO.WebBrowser.MenuItem("Essential Objects Homepage", m_nHomeCommand));
e.Menu.Items.Add(EO.WebBrowser.MenuItem.CreateSeparator());
e.Menu.Items.Add(new EO.WebBrowser.MenuItem("Back", CommandIds.Back));
e.Menu.Items.Add(new EO.WebBrowser.MenuItem("Forward", CommandIds.Forward));
}

The above code clears the default context menu and added four custom context menu items (three command items and one separator).

A menu item is associated to a "command", which can be one of the several built-in command Ids as defined on the CommandIds class, or a custom command. See here for more information about handling custom command.