Skip to content

Commit 335fa0b

Browse files
nidibleaanthony
andauthored
[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 <[email protected]>
1 parent ff6a333 commit 335fa0b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

v3/UNRELEASED_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ After processing, the content will be moved to the main changelog and this file
1717

1818
## Added
1919
<!-- New features, capabilities, or enhancements -->
20+
- macOS: Shows native window controls in the menu bar in [#4588](https://github.com/wailsapp/wails/pull/4588) by @nidib
2021
- Add macOS Dock service to hide/show app icon in the dock @popaprozac in [PR](https://github.com/wailsapp/wails/pull/4451)
2122

2223
## Changed

v3/examples/menu/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ func main() {
146146

147147
app.Menu.Set(menu)
148148

149-
window := app.Window.New().SetBackgroundColour(application.NewRGB(33, 37, 41))
149+
window := app.Window.NewWithOptions(application.WebviewWindowOptions{
150+
Name: "menu-example",
151+
Title: "Menu Example",
152+
}).SetBackgroundColour(application.NewRGB(33, 37, 41))
150153
window.SetMenu(menu)
151154

152155
err := app.Run()

v3/pkg/application/menu_darwin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ static void addServicesMenu(void* menu) {
5353
[NSApp setServicesMenu:nsMenu];
5454
}
5555
56+
// Add windows menu
57+
void addWindowsMenu(void* menu) {
58+
NSMenu *nsMenu = (__bridge NSMenu *)menu;
59+
[NSApp setWindowsMenu:nsMenu];
60+
}
61+
5662
5763
*/
5864
import "C"
@@ -96,6 +102,9 @@ func (m *macosMenu) processMenu(parent unsafe.Pointer, menu *Menu) {
96102
if item.role == ServicesMenu {
97103
C.addServicesMenu(nsSubmenu)
98104
}
105+
if item.role == WindowMenu {
106+
C.addWindowsMenu(nsSubmenu)
107+
}
99108
case text, checkbox, radio:
100109
menuItem := newMenuItemImpl(item)
101110
item.impl = menuItem

0 commit comments

Comments
 (0)