Reputation:
I have an NSTableView
where I use the
tableView(tableView:shouldTypeSelectFor:withCurrentSearch:) -> Bool
delegate method to select certain lines with the SPACE
key like this
func tableView(_ tableView: NSTableView,
shouldTypeSelectFor event: NSEvent,
withCurrentSearch searchString: String?) -> Bool {
if event.charactersIgnoringModifiers == " " {
// Perform action on currently selected row(s)
}
return false
}
That works fine, but when the setting in
Preferences > Keyboard > Shortcuts > "Use keyboard navigation to move focus between controls"
Is turned on, the table view loses focus entirely after hitting the SPACE
key.
If I check my responder chain afterwards, I can se that the focus moved back to the window.
Another sideeffect of turning this setting on is that if I have a check box (NSButton
) in the selected table view cell, its action will be automatically called when hitting SPACE
.
The setting explicitly states it only moves focus on TAB
and SHIFT+TAB
, not change how controls work.
Why does this happen? Can I disable this behavior at least partially for the table view of the app?
Upvotes: 1
Views: 349
Reputation:
After almost losing my last hair here is what resolves it
refusesFirstResponder
set to false
Now the table views first responder status is not lost.
Upvotes: 2