Electron.net: macOS menu support

Created on 24 Oct 2017  路  4Comments  路  Source: ElectronNET/Electron.NET

The Menu API needs an other Menu implementation for the macOS:
https://electron.atom.io/docs/api/menu/#notes-on-macos-application-menu

Feature help wanted

All 4 comments

Is this still needed? I'll do this.

Hi, yes that would be great!

Here is a video tutorial on how to code at Electron.NET:
https://youtu.be/Po-saU_Z6Ws

Yeah, I'm following it right now

@GregorBiswanger making menus for Mac doesn't seem to need modifications to API.
I made this menu using our existing API.
Screen Shot 2020-10-06 at 10 19 03 AM

You just have to format the menu according to official Electron's Menu.
Just follow the ones with the isMac boolean check.

Here's the code I used.

var menu = new MenuItem[]
            {
                new MenuItem
                {
                    Label = "Prefix",
                    Submenu = new MenuItem[]
                    {
                        new MenuItem { Role = MenuRole.about },
                        new MenuItem { Type = MenuType.separator },
                        new MenuItem { Role = MenuRole.services },
                        new MenuItem { Type = MenuType.separator },
                        new MenuItem { Role = MenuRole.hide },
                        new MenuItem { Role = MenuRole.hideothers },
                        new MenuItem { Type = MenuType.separator },
                        new MenuItem { Role = MenuRole.quit }
                    }
                },
                new MenuItem
                {
                    Label = "MacTest",
                    Submenu = new MenuItem[]
                    {
                        new MenuItem { Label = "Do nothing."}
                    }
                },
                new MenuItem
                {
                    Label = "View",
                    Submenu = new MenuItem[]
                    {
                        new MenuItem { Role = MenuRole.reload },
                        new MenuItem { Role = MenuRole.toggledevtools }
                    }
                }
            };

            Electron.Menu.SetApplicationMenu(menu);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

robalexclark picture robalexclark  路  6Comments

thnk2wn picture thnk2wn  路  4Comments

AykutToprak picture AykutToprak  路  4Comments

BrianAllred picture BrianAllred  路  5Comments

ThuCommix picture ThuCommix  路  3Comments