mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-27 18:38:49 +00:00
Merge pull request #1905 from ahankinson/fix-cptableview-shouldselectrow-delegate
Fixed: Delegate method fires twice when using keyboard to select rows in...
This commit is contained in:
commit
e95856dadd
1 file changed
+13
-5
+13
-5
@@ -5258,13 +5258,21 @@ 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))
|
||||
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 (!shouldSelect)
|
||||
{
|
||||
/* If shouldSelect returns NO it means this row cannot be selected.
|
||||
The proper behaviour is to then try to see if the next/previous
|
||||
row(s) can be selected, until we hit the first one that can be.
|
||||
*/
|
||||
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
|
||||
shouldSelect = [_delegate tableView:self shouldSelectRow:i];
|
||||
}
|
||||
}
|
||||
|
||||
// If the index still can be selected after the loop then just return.
|
||||
if (![_delegate tableView:self shouldSelectRow:i])
|
||||
return;
|
||||
}
|
||||
|
||||
// If we go upward and see that this row is already selected we should deselect the row below.
|
||||
|
||||
Reference in new issue
Block a user