My table view supports multiple selection. When holding down the shift key and clicking to extend the selection on Mac focus doesn't move to the clicked row. This isn't how macOS apps normally behave.
I tried working around the problem by catching the last selected index path and forcing a focus update:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.lastSelectedIndexPath = indexPath;
}
-(void)tableView:(UITableView*)tableView didDeselectRowAtIndexPath:(NSIndexPath*)indexPath
{
if ([indexPath isEqual:self.lastSelectedIndexPath])
{
self.lastSelectedIndexPath = nil;
}
}
-(void)tableViewDidEndMultipleSelectionInteraction:(UITableView *)tableView
{
[tableView setNeedsFocusUpdate];
[tableView updateFocusIfNeeded];
}
-(NSIndexPath*)indexPathForPreferredFocusedViewInTableView:(UITableView *)tableView
{
return self.lastSelectedIndexPath;
}
But that didn't work. UITableview never calls -indexPathForPreferredFocusedViewInTableView: after my -setNeedsFocusUpdate / -updateFocusIfNeeded calls.
I tried subclassing UITableView and overriding -preferredFocusEnvironments but that isn't called.
Focus system just ignores updating for shift click. Anyone know of a workaround?