Skip to content

Commit

Permalink
Using a scroll wheel now changes the selection as appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
mattball committed Mar 27, 2009
1 parent 9d5fc57 commit 5b22847
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions MBCoverFlowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ of this software and associated documentation files (the "Software"), to deal
const float MBCoverFlowScrollerHorizontalMargin = 80.0;
const float MBCoverFlowScrollerVerticalSpacing = 16.0;

const float MBCoverFlowScrollMinimumDeltaThreshold = 0.4;

#define MBCoverFlowViewContainerMinY (NSMaxY([self.accessoryController.view frame]) - 3*[self itemSize].height/4)

// Perspective parameters
Expand Down Expand Up @@ -276,6 +278,23 @@ - (void)mouseDown:(NSEvent *)theEvent
}
}

- (void)scrollWheel:(NSEvent *)theEvent
{
if (fabs([theEvent deltaY]) > MBCoverFlowScrollMinimumDeltaThreshold) {
if ([theEvent deltaY] > 0) {
self.selectionIndex -= 1;
} else {
self.selectionIndex += 1;
}
} else if (fabs([theEvent deltaX]) > MBCoverFlowScrollMinimumDeltaThreshold) {
if ([theEvent deltaX] > 0) {
self.selectionIndex -= 1;
} else {
self.selectionIndex += 1;
}
}
}

#pragma mark NSView

- (void)viewWillMoveToSuperview:(NSView *)newSuperview
Expand Down

0 comments on commit 5b22847

Please sign in to comment.