Submenu not shown #493

Closed
opened 2026-01-29 16:41:05 +00:00 by claunia · 1 comment
Owner

Originally created by @graylobo on GitHub (May 14, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version: 8.31.2
  • Target:

I'm trying to make 'One' menu, and 'Two' submenu.
my code is below

Task.Run(async () => { var options = new BrowserWindowOptions { Show = true }; Electron.Menu.SetApplicationMenu(new MenuItem[] { new MenuItem { Label = "One" ,Submenu = new MenuItem[] { new MenuItem {Label="Two" } } } }); await Electron.WindowManager.CreateWindowAsync(); });

It makes 'One' menu, but nothing happen when i click it.
20200514_183345
And this github demo also does not display submenu.
https://github.com/ElectronNET/electron.net-api-demos
Can i know what am I missing?

Originally created by @graylobo on GitHub (May 14, 2020). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: 8.31.2 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> <!-- What target are you building for? --> * **Target**: <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> I'm trying to make 'One' menu, and 'Two' submenu. my code is below ` Task.Run(async () => { var options = new BrowserWindowOptions { Show = true }; Electron.Menu.SetApplicationMenu(new MenuItem[] { new MenuItem { Label = "One" ,Submenu = new MenuItem[] { new MenuItem {Label="Two" } } } }); await Electron.WindowManager.CreateWindowAsync(); }); ` It makes 'One' menu, but nothing happen when i click it. ![20200514_183345](https://user-images.githubusercontent.com/37823841/81919252-90bb6780-9612-11ea-9f92-2be8dcb1b5d3.png) And this github demo also does not display submenu. https://github.com/ElectronNET/electron.net-api-demos Can i know what am I missing?
claunia added the question label 2026-01-29 16:41:05 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (May 15, 2020):

You forgot to set the type for it as a submenu:

Task.Run(async () =>
{
    var menu = new MenuItem[]
    {
            new MenuItem
            {
                Label = "One",
                Type = MenuType.submenu,
                Submenu = new MenuItem[]
                {
                    new MenuItem
                    {
                        Label = "Two"
                    },
                    new MenuItem
                    {
                        Label = "Three"
                    }
                }
            }
    };

    Electron.Menu.SetApplicationMenu(menu);

    await Electron.WindowManager.CreateWindowAsync();
});

electron-net-submenu-problem

@GregorBiswanger commented on GitHub (May 15, 2020): You forgot to set the type for it as a submenu: ``` Task.Run(async () => { var menu = new MenuItem[] { new MenuItem { Label = "One", Type = MenuType.submenu, Submenu = new MenuItem[] { new MenuItem { Label = "Two" }, new MenuItem { Label = "Three" } } } }; Electron.Menu.SetApplicationMenu(menu); await Electron.WindowManager.CreateWindowAsync(); }); ``` ![electron-net-submenu-problem](https://user-images.githubusercontent.com/7336300/82088750-9b4d2e00-96f2-11ea-80b9-9996674ad5be.gif)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#493