I have a simple document-based application for macOS.
struct ContentView: View {
@Binding var document: TextDocument
var body: some View {
.onReceive(NotificationCenter.default.publisher(for: .notificationTextWillAppendSomeTextt), perform: { _ in
})
VStack {
TextEditor(text: $document.text)
}
}
}
extension Notification.Name {
static let notificationTextWillAppendSomeTextt = Notification.Name("TextWillAppendSomeText")
}
Suppose that my application currently has three tabs. If I call a menu command through
post(name:object:)
this menu command call will affect all three of them. This stackoverflow topic talks about it, too. So how could I tell which window should get a call and others don't? Thanks.