diff --git a/website/docs/reference/menus.mdx b/website/docs/reference/menus.mdx index 7af0bf38fe3..4a9b4da1bf6 100644 --- a/website/docs/reference/menus.mdx +++ b/website/docs/reference/menus.mdx @@ -15,15 +15,21 @@ An example of how to create a menu: app := NewApp() AppMenu := menu.NewMenu() + if runtime.GOOS == "darwin" { + AppMenu.Append(menu.AppMenu()) // On macOS platform, this must be done right after `NewMenu()` + } FileMenu := AppMenu.AddSubmenu("File") - FileMenu.AddText("&Open", keys.CmdOrCtrl("o"), openFile) + FileMenu.AddText("&Open", keys.CmdOrCtrl("o"), func(_ *menu.CallbackData) { + // do something + }) FileMenu.AddSeparator() FileMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) { - runtime.Quit(app.ctx) + // `rt` is an alias of "github.com/wailsapp/wails/v2/pkg/runtime" to prevent collision with standard package + rt.Quit(app.ctx) }) if runtime.GOOS == "darwin" { - AppMenu.Append(menu.EditMenu()) // on macos platform, we should append EditMenu to enable Cmd+C,Cmd+V,Cmd+Z... shortcut + AppMenu.Append(menu.EditMenu()) // On macOS platform, EditMenu should be appended to enable Cmd+C, Cmd+V, Cmd+Z... shortcuts } err := wails.Run(&options.App{ diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 46227e41a06..8c0e3e473bd 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying) - Using go-webview2 v0.1.17 to fix native webview2loader issue, by @leaanthony +- Fixed example for macOS menu by @takuyahara in [PR](https://github.com/wailsapp/wails/pull/3847) ### Changed - Allow to specify macos-min-version externally. Implemented by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/3756)