I'm trying to update the menu items in the main menu for a SwiftUI macOS app (not Catalyst). I haven't been able to find any way to do it.
The menu items are always as they are when first loaded. :(
Is there a way to "validate" commands in SwiftUI?
Examples for why you change menu items: "show" or "hide" title change, disabled item, or toggle state.
The ".disabled" modifier needs to update in this example.
The menu items are always as they are when first loaded. :(
Is there a way to "validate" commands in SwiftUI?
Examples for why you change menu items: "show" or "hide" title change, disabled item, or toggle state.
Code Block CommandGroup(replacing: CommandGroupPlacement.toolbar) { Button(action: { NotificationCenter.default.post(name: .SortByName, object: nil) }) { Text(NSLocalizedString("Sort by \(sortType.rawValue)", comment: "key command for sorting all dates by name"))} .keyboardShortcut("1", modifiers: .command) .disabled(sortType == .name)
The ".disabled" modifier needs to update in this example.