From 335fa0bcc5887fc63ef7f99719c3115ef5d39fdf Mon Sep 17 00:00:00 2001 From: Richard Bidin Date: Thu, 25 Sep 2025 00:30:59 -0300 Subject: [PATCH] [V3 Alpha] Improves macOS Window menu support (#4588) * feat: Binds window menu to app windows * chore: disables tab feature & controls from menu by default * docs: Adds title to example for it to show in the window menu item * style: removes redundant SetBackgroundColor call * chore: rolls back disabling tab controls for a future optional config * docs: adds change description to unreleased notes --------- Co-authored-by: Lea Anthony --- v3/UNRELEASED_CHANGELOG.md | 1 + v3/examples/menu/main.go | 5 ++++- v3/pkg/application/menu_darwin.go | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/v3/UNRELEASED_CHANGELOG.md b/v3/UNRELEASED_CHANGELOG.md index f0013f982..007a4e413 100644 --- a/v3/UNRELEASED_CHANGELOG.md +++ b/v3/UNRELEASED_CHANGELOG.md @@ -17,6 +17,7 @@ After processing, the content will be moved to the main changelog and this file ## Added +- macOS: Shows native window controls in the menu bar in [#4588](https://github.com/wailsapp/wails/pull/4588) by @nidib - Add macOS Dock service to hide/show app icon in the dock @popaprozac in [PR](https://github.com/wailsapp/wails/pull/4451) ## Changed diff --git a/v3/examples/menu/main.go b/v3/examples/menu/main.go index 0349eceb6..53981cbad 100644 --- a/v3/examples/menu/main.go +++ b/v3/examples/menu/main.go @@ -146,7 +146,10 @@ func main() { app.Menu.Set(menu) - window := app.Window.New().SetBackgroundColour(application.NewRGB(33, 37, 41)) + window := app.Window.NewWithOptions(application.WebviewWindowOptions{ + Name: "menu-example", + Title: "Menu Example", + }).SetBackgroundColour(application.NewRGB(33, 37, 41)) window.SetMenu(menu) err := app.Run() diff --git a/v3/pkg/application/menu_darwin.go b/v3/pkg/application/menu_darwin.go index a17031489..5c315ffd2 100644 --- a/v3/pkg/application/menu_darwin.go +++ b/v3/pkg/application/menu_darwin.go @@ -53,6 +53,12 @@ static void addServicesMenu(void* menu) { [NSApp setServicesMenu:nsMenu]; } +// Add windows menu +void addWindowsMenu(void* menu) { + NSMenu *nsMenu = (__bridge NSMenu *)menu; + [NSApp setWindowsMenu:nsMenu]; +} + */ import "C" @@ -96,6 +102,9 @@ func (m *macosMenu) processMenu(parent unsafe.Pointer, menu *Menu) { if item.role == ServicesMenu { C.addServicesMenu(nsSubmenu) } + if item.role == WindowMenu { + C.addWindowsMenu(nsSubmenu) + } case text, checkbox, radio: menuItem := newMenuItemImpl(item) item.impl = menuItem