Why does it need to be so difficult replacing the default menu items in a native #macOS app???
Like, it's not because the code is super difficult and complex. In fact, the code is really simple, but there is just no documentation provided by Apple on how to manipulate the default menu items, like 'Close' in 'File' menu with the `CMD + W` shortcut.
I tried using `CommandGroup(replacing: .saveItem)` and then providing the function I would like to call whenever the user clicks the shortcut `CMD + W`. But no, that didn't work.
Googled with limited success, but eventually found something useful on Stackoverflow:
https://stackoverflow.com/questions/74417490/swiftui-update-the-mainmenu-solved-kludgey
Login to reply
Replies (1)
It's also pretty weird that `.saveItem` is for closing windows, but it is (and for 'Save' and 'Save All' commands, but that's more obvious considering the name).
https://developer.apple.com/documentation/swiftui/commandgroupplacement/saveitem