I have a view that contains an NSTableView and an NSTextField. The table view has focus. I would like to use the text field as a filter for the table view. Is there any way that I can send a key press event, which is captured by the table view, to the NSTextField?
Here is the keyDown func as I have it, I would like to send theEvent to the text field in the default handler of the switch statement.
override func keyDown(theEvent: NSEvent) {
let s = theEvent.charactersIgnoringModifiers!
let s1 = s.unicodeScalars
let s2 = s1[s1.startIndex].value
let s3 = Int(s2)
switch s3 {
case NSUpArrowFunctionKey:
self.previous()
return
case NSDownArrowFunctionKey:
self.next()
return
default:
// this appends the text to the textField, Is there a way to send theEvent to the textField?
textField.stringValue = textField.stringValue + s;
// textField.keyDown(theEvent) // this does not work
break
}
}
I would like to not have to force the user to change focus to the text field in order to filter the table view results.
NSSearchField
and do type-to-select in the table. – Ken Thomases