|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
I would like to add a new MenuItem on EO.WebBrowser which looks like "Copy" on right click. Whenever user selects a text and does right click, the context menu will display my menu item. Without selecting a text, this menu item will not show up on right click.
Thank you.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You will need to handle the WebView's BeforeContextMenu event and then check e.MenuInfo.SourceFlags. For example, the following code creates a custom context menu and only if the source is a selection, the copy menu item is added into the context menu:
Code: C#
void WebView_BeforeContextMenu(object sender, BeforeContextMenuEventArgs e)
{
//Clear the default context menu
e.Menu.Items.Clear();
//Add other menu items
....
//Only add "Copy" menu item if the source of the context menu is a selection
if ((e.MenuInfo.SourceFlags & ContextMenuSourceFlags.Selection) != 0)
e.Menu.Items.Add(new EO.WebBrowser.MenuItem("Copy", CommandIds.Copy));
}
Hope this helps. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
The code works great. It is exactly what I am looking for. Thank you!
|
|