So, I have an app where I have replaced the copy/paste menu item with custom code. I need to be able to use copy/paste to copy and paste a custom object, so I call to functions in my view model:
Button("Copy") {
mainViewModel?.copyToPasteBoard()
}
.keyboardShortcut("c", modifiers: .command)
.disabled(!hasSelection)
Button("Paste") {
mainViewModel?.pasteFromPasteboard()
}
.keyboardShortcut("v", modifiers: .command)
.disabled(!hasSelection)
This works great.
However, I also have a popup sheet that allows me to edit my data. Nothing special in there, just some TextFields:
TextField("", text: $vm.text)
.themedFont(for: .nodeEditTitle)
.padding(.bottom)
The problem I don't know how to address is, when editing the data, I can press <ctrl>c and <ctrl>v to copy and paste data in the TextField, but it's the menu that is triggered and that,in turn, calls my view model to copy and paste the object. I can stop the view model doing the copy and paste by detecting whether the edit sheet is displayed, but the copy/paste isn't passed on to the TextField in the sheet.
What I need to be able to do is direct <ctrl>c and <ctrl>v to the TextField on the sheet and to ignore the menu. I don't know how to do that.
Thanks
Steve.