Thanks, that did help.
For completeness, I wrote this small sample app that adds a new menu item to the menu and overrides the copy menu.
@main
struct MenuTestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.commands {
CommandMenu("My Top Menu") {
Button("Sub Menu Item") { print("You pressed sub menu.") }
.keyboardShortcut("S")
}
CommandGroup(replacing: .pasteboard) {
Button("Cut") { print("Cutting something...") }
.keyboardShortcut("X")
Button("Copy") { print("Copying something...") }
.keyboardShortcut("C")
Button("Paste") { print("Pasting something...") }
.keyboardShortcut("V")
Button("Paste and Match Style") { print("Pasting and Matching something...") }
.keyboardShortcut("V", modifiers: [.command, .option, .shift])
Button("Delete") { print("Deleting something...") }
.keyboardShortcut(.delete)
Button("Select All") { print("Selecting something...") }
.keyboardShortcut("A")
}
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: