Browse files

* Fixed issue with clicking on layers to select the item

  • Loading branch information...
1 parent b6cfbe5 commit b83aa58c31a3db9a95da87f1aa85b8e12dd05425 @mattball committed Apr 28, 2009
Showing with 7 additions and 3 deletions.
  1. +7 −3 MBCoverFlowView.m
View
10 MBCoverFlowView.m
@@ -579,6 +579,10 @@ - (void)setSelectedIndex:(NSInteger)newIndex
- (id)selectedObject
{
+ if ([self.content count] == 0) {
+ return nil;
+ }
+
return [self.content objectAtIndex:self.selectedIndex];
}
@@ -613,7 +617,7 @@ - (NSInteger)indexOfItemAtPoint:(NSPoint)aPoint
// Check the items to the right, in ascending order
index = self.selectedIndex+1;
- while (index < [[_scrollLayer sublayers] count]) {
+ while (index < [self.content count]) {
NSRect layerRect = [self rectForItemAtIndex:index];
if (NSPointInRect(aPoint, layerRect)) {
return index;
@@ -627,11 +631,11 @@ - (NSInteger)indexOfItemAtPoint:(NSPoint)aPoint
// FIXME: The frame returned is not quite wide enough. Don't know why -- probably due to the transforms
- (NSRect)rectForItemAtIndex:(NSInteger)index
{
- if (index < 0 || index >= [[_scrollLayer sublayers] count]) {
+ if (index < 0 || index >= [self.content count]) {
return NSZeroRect;
}
- CALayer *layer = [[_scrollLayer sublayers] objectAtIndex:index];
+ CALayer *layer = [self _layerForObject:[self.content objectAtIndex:index]];
CALayer *imageLayer = [[layer sublayers] objectAtIndex:0];
CGRect frame = [imageLayer convertRect:[imageLayer frame] toLayer:self.layer];

0 comments on commit b83aa58

Please sign in to comment.