As far as I checked, your Coordinator does not have any methods defined in NSTextFieldDelegate.
You should better try something like this:
extension OrderedTextField {
class Coordinator: NSObject, NSTextFieldDelegate {
@Binding var text: String
var newSelection: (Int) -> () = { _ in }
init(text: Binding<String>) {
print("Initializing!")
_text = text
}
func textField(_ textField: NSTextField, textView: NSTextView, candidatesForSelectedRange selectedRange: NSRange) -> [Any]? {
print(#function)
return nil
}
func textField(_ textField: NSTextField, textView: NSTextView, candidates: [NSTextCheckingResult], forSelectedRange selectedRange: NSRange) -> [NSTextCheckingResult] {
print(#function)
return candidates
}
func textField(_ textField: NSTextField, textView: NSTextView, shouldSelectCandidateAt index: Int) -> Bool {
print(#function)
return true
}
func controlTextDidBeginEditing(_ obj: Notification) {
print(#function)
}
func controlTextDidEndEditing(_ obj: Notification) {
print(#function)
}
func controlTextDidChange(_ obj: Notification) {
print(#function)
}
func control(_ control: NSControl, textShouldBeginEditing fieldEditor: NSText) -> Bool {
print(#function)
return true
}
func control(_ control: NSControl, textShouldEndEditing fieldEditor: NSText) -> Bool {
print(#function)
return true
}
//...
}
}
Or you may try subclassing NSTextField and override methods like textShouldBeginEditing(_:), textDidBeginEditing(_:), textDidChange(_:) ... in the subclass.