mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge pull request #1842 from stewa/empty-collectionview-keyboard-navigation-problem
Fixed: using keyboard navigation in empty CPCollectionView threw exception
Previously, if an empty CPCollectionView was first responder and keyboard navigation was used, a CPInvalidArgumentException (Range {-1, 1} is out of bounds) was thrown.
This commit checks for an empty collection, eliminating the exception.
This commit is contained in:
@@ -1210,7 +1210,12 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
|
||||
- (void)_modifySelectionWithNewIndex:(int)anIndex direction:(int)aDirection expand:(BOOL)shouldExpand
|
||||
{
|
||||
anIndex = MIN(MAX(anIndex, 0), [[self items] count] - 1);
|
||||
var count = [[self items] count];
|
||||
|
||||
if (count === 0)
|
||||
return;
|
||||
|
||||
anIndex = MIN(MAX(anIndex, 0), count - 1);
|
||||
|
||||
if (_allowsMultipleSelection && shouldExpand)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user