macOS menu support #24

Closed
opened 2026-01-29 16:27:45 +00:00 by claunia · 5 comments
Owner

Originally created by @GregorBiswanger on GitHub (Oct 24, 2017).

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

Originally created by @GregorBiswanger on GitHub (Oct 24, 2017). The Menu API needs an other Menu implementation for the macOS: https://electron.atom.io/docs/api/menu/#notes-on-macos-application-menu
claunia added the help wantedFeature labels 2026-01-29 16:27:45 +00:00
Author
Owner

@rakista112 commented on GitHub (Oct 1, 2020):

Is this still needed? I'll do this.

@rakista112 commented on GitHub (Oct 1, 2020): Is this still needed? I'll do this.
Author
Owner

@GregorBiswanger commented on GitHub (Oct 1, 2020):

Hi, yes that would be great!

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

@GregorBiswanger commented on GitHub (Oct 1, 2020): Hi, yes that would be great! Here is a video tutorial on how to code at Electron.NET: https://youtu.be/Po-saU_Z6Ws
Author
Owner

@rakista112 commented on GitHub (Oct 4, 2020):

Yeah, I'm following it right now

@rakista112 commented on GitHub (Oct 4, 2020): Yeah, I'm following it right now
Author
Owner

@rakista112 commented on GitHub (Oct 6, 2020):

@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);
@rakista112 commented on GitHub (Oct 6, 2020): @GregorBiswanger making menus for Mac doesn't seem to need modifications to API. I made this menu using our existing API. <img width="947" alt="Screen Shot 2020-10-06 at 10 19 03 AM" src="https://user-images.githubusercontent.com/815354/95151688-e0671f00-07bd-11eb-8763-184d5754b54f.png"> 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); ```
Author
Owner

@cosmo0 commented on GitHub (Mar 16, 2021):

Can confirm that it works fine.

The only weird thing is that in MacOS there is no "quit" option so cmd+Q doesn't work out of the gates.

@cosmo0 commented on GitHub (Mar 16, 2021): Can confirm that it works fine. The only weird thing is that in MacOS there is no "quit" option so cmd+Q doesn't work out of the gates.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#24