mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Fixed example for macOS menu (#3847)
* Fixed example for macOS menu * Update changelog.mdx
This commit is contained in:
parent
bdb415130b
commit
1c163422aa
2 changed files with 10 additions and 3 deletions
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue