Fixed: Delegate method fires twice when using keyboard to select rows in table view

Previously, navigating through the rows of a tableview with the arrow keys would cause the delegate method `- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex` to fire twice. This was due to the delegate method being called twice in checking whether the row could be selected.

This commit changes it so that the delegate method is called just once and the result stored.
This commit is contained in:
Andrew Hankinson
2013-04-15 11:46:58 -04:00
parent 4c756c7cbf
commit 6e2dcd5dcb
+3 -2
View File
@@ -5235,12 +5235,13 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_shouldSelectRow_)
{
var shouldSelect = [_delegate tableView:self shouldSelectRow:i];
while (![_delegate tableView:self shouldSelectRow:i] && (i < [self numberOfRows] && i > 0))
while (!shouldSelect && (i < [self numberOfRows] && i > 0))
shouldGoUpward ? i-- : i++; //check to see if the row can be selected if it can't be then see if the next row can be selected
// If the index still can be selected after the loop then just return.
if (![_delegate tableView:self shouldSelectRow:i])
if (!shouldSelect)
return;
}