|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi, I have the problem to show sub menu items of a menu item in EO.WebBrowser. Here is the code snippet to check:
Code: C#
private static MenuItem mainMenu;
private static MenuItem subMenu1;
private void webView_BeforeContextMenu(object sender, BeforeContextMenuEventArgs e)
{
mainMenu = new MenuItem("Copy selected text to");
subMenu1 = new MenuItem("Program 1", _program1ID);
if ((e.MenuInfo.SourceFlags & ContextMenuSourceFlags.Selection) != 0)
{
if (!e.Menu.Items.Contains(mainMenu))
{
e.Menu.Items.Add(mainMenu); // Add the main menu
mainMenu.SubItems.Add(subMenu1); // Add the sub menu to this main menu
}
}
}
After running this code, subMenu1 is not added into mainMenu, it added to the same level of mainMenu at the end of the context menu. Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,275
|
Hi, Please try the following: 1. Update to the latest build; 2. Switch the order of the two Add calls from:
Code: C#
e.Menu.Items.Add(mainMenu); // Add the main menu
mainMenu.SubItems.Add(subMenu1); // Add the sub menu to this main menu
To:
Code: C#
mainMenu.SubItems.Add(subMenu1); // Add the sub menu to this main menu
e.Menu.Items.Add(mainMenu); // Add the main menu
Once you switch the order, it should work in the current build. There is an issue in our current build that won't create the sub menu items if you use your original code. This will be fixed in our next build. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
This little fix to swap the order works! Thank you very much.
-Dylan
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,275
|
Glad to hear that it works for you! Please feel free to let us know if you still have any questions.
Thanks!
|
|