Welcome Guest Search | Active Topics | Sign In | Register

Sub menu not show in context menu of EO.WebBrowser Options
Khoa
Posted: Tuesday, July 5, 2016 11:30:34 AM
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.
eo_support
Posted: Tuesday, July 5, 2016 12:48:16 PM
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!
Khoa
Posted: Tuesday, July 5, 2016 12:58:15 PM
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
eo_support
Posted: Tuesday, July 5, 2016 3:43:22 PM
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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.