[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 <lea.anthony@gmail.com>
This commit is contained in:
Richard Bidin 2025-09-25 00:30:59 -03:00 committed by GitHub
commit 335fa0bcc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View file

@ -17,6 +17,7 @@ After processing, the content will be moved to the main changelog and this file
## Added
<!-- New features, capabilities, or enhancements -->
- 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

View file

@ -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()

View file

@ -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