From 49b524d16932e5ab93762f04d94dd1935cb5f58f Mon Sep 17 00:00:00 2001 From: stffabi Date: Mon, 10 Feb 2025 10:59:16 +0100 Subject: [PATCH] [v2, darwin] Fix updating menus (#4057) --- v2/internal/frontend/desktop/darwin/window.go | 12 +++++++++--- website/src/pages/changelog.mdx | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/v2/internal/frontend/desktop/darwin/window.go b/v2/internal/frontend/desktop/darwin/window.go index 121533a33..04b9f888d 100644 --- a/v2/internal/frontend/desktop/darwin/window.go +++ b/v2/internal/frontend/desktop/darwin/window.go @@ -32,6 +32,8 @@ func init() { type Window struct { context unsafe.Pointer + + applicationMenu *menu.Menu } func bool2Cint(value bool) C.int { @@ -292,12 +294,16 @@ func (w *Window) Size() (int, int) { } func (w *Window) SetApplicationMenu(inMenu *menu.Menu) { - mainMenu := NewNSMenu(w.context, "") - processMenu(mainMenu, inMenu) - C.SetAsApplicationMenu(w.context, mainMenu.nsmenu) + w.applicationMenu = inMenu + w.UpdateApplicationMenu() } func (w *Window) UpdateApplicationMenu() { + mainMenu := NewNSMenu(w.context, "") + if w.applicationMenu != nil { + processMenu(mainMenu, w.applicationMenu) + } + C.SetAsApplicationMenu(w.context, mainMenu.nsmenu) C.UpdateApplicationMenu(w.context) } diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 677d2bc3f..894da5b89 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed Dispatcher.ProcessMessage crash process instead of return error [PR](https://github.com/wailsapp/wails/pull/4016) [#4015](https://github.com/wailsapp/wails/issues/4015) by [@ronaldinho_x86](https://github.com/RonaldinhoL) - Fixed Windows SaveDialog crash by [@leaanthony](https://github.com/leaanthony) - Fixed `buildvcs` errors by [@leaanthony](https://github.com/leaanthony) +- Fixed updating menus on MacOS by [@stffabi](https://github.com/stffabi) ### Changed - Removed documentation references for 'The default module name in go.mod is "changeme". You should change this to something more appropriate.' as it appears to be no longer relevant.