내 NSViewController 내용이 변경 될 때마다 알림을 실행하는 NSTexField가 있습니다.텍스트 변경에 대한 신속한 macOS 알림
또한 IBActions가 NSTextField에 문자를 쓰도록 정의 된 버튼이 여러 개 있습니다. 그러나 단추 중 하나를 누를 때마다 NSTextField가 업데이트됩니다. 알림은 시작되지 않습니다.
수동으로 NSControlTextDidChange 이벤트를 발생시키는 방법은 무엇입니까? 이 맥 응용 프로그램이기 때문에
override func controlTextDidChange(_ notification: Notification) {
if let textField = notification.object as? NSTextField {
filterTable(with: textField.stringValue)
}
}
@IBAction func pressedKeyButton(_ sender: NSButton) {
let character = sender.title
self.searchTextField.stringValue.append(character)
self.searchTextField.textDidChange(Notification(name: .NSControlTextDidChange,object: nil))
}
"self.searchTextField.textDidChange (Notification (name : .NSControlTextDidChange, object : nil))"란 무엇입니까? 귀하의 controlTextDidChange가 맞지 않는 것 같습니다. –
pressedKeyButton 동작이 트리거되면 NSTexField의 내용은 업데이트되지만 controlTextDidChange 함수는 트리거되지 않습니다. –