asticode / go-astilectron

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)
MIT License
4.9k stars 344 forks source link

MacOS menu not displayed #352

Closed roromix closed 2 years ago

roromix commented 2 years ago

I have tried to add a menu directly to the app, it display properly on Windows but isn't displayed on MacOS

    m := a.NewMenu([]*astilectron.MenuItemOptions{
        {
            Label: astikit.StrPtr("Menu1"),
            OnClick: func(e astilectron.Event) (deleteLister bool) {
                window.SendMessage("menu1")
                return
            },
        },
        {
            Label: astikit.StrPtr("Menu 2"),
            OnClick: func(e astilectron.Event) (deleteLister bool) {
                window.SendMessage("menu2")
                return
            },
        },
        {
            Label: astikit.StrPtr("Help"),
            SubMenu: []*astilectron.MenuItemOptions{
                {
                    Label: astikit.StrPtr("About"),
                    OnClick: func(e astilectron.Event) (deleteLister bool) {
                        createAboutPopin()
                        return
                    },
                },
            },
        },
    })
    err := m.Create()
    checkError(err)

Has anyone ever managed to display a menu on MacOS, and how?

asticode commented 2 years ago

The menu in the demo should be working in MacOS. If you only keep the third item in your menu, does it work in MacOS (I think menus need to have a SubMenu in MacOS)

roromix commented 2 years ago

@asticode : Yes, I have tested, it's now ok. Thanks a lot

And i have created a PR