Skip to content

Instantly share code, notes, and snippets.

@curthard89
Created January 13, 2012 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curthard89/1608395 to your computer and use it in GitHub Desktop.
Save curthard89/1608395 to your computer and use it in GitHub Desktop.
// this is the cure to fix the scrollers
- (NSView *)hitTest:(NSPoint)aPoint
{
// CHANGE NEXT LINE TO HOW YOU CHECK FOR LION, UNLESS YOUR APP
// ONLY WORKS ON LION THEN JUST DELETE THE IF
// are we running lion?
if( ! IS_RUNNING_LION )
{
// if we are not, dont bother with the
return [super hitTest:aPoint];
}
NSEvent * currentEvent = [NSApp currentEvent];
// listen for mouse down
if( [currentEvent type] == NSLeftMouseDown )
{
BOOL flag = NO;
// if we have a vertical scroller and it accepts the current hit
if( [self hasVerticalScroller] && [[self verticalScroller] hitTest:aPoint] != nil )
{
flag = YES;
[[self verticalScroller] mouseDown:currentEvent];
}
// if we have a horizontal scroller and it accepts the current hit
if( [self hasVerticalScroller] && [[self horizontalScroller] hitTest:aPoint] != nil )
{
flag = YES;
[[self horizontalScroller] mouseDown:currentEvent];
}
// return nil only if flag is set, otherwise it will continue
// down the view hierarchy which is not what we want!
if( flag )
{
return nil;
}
} else if( [currentEvent type] == NSLeftMouseUp ) {
// if mouse up, just tell both our scrollers we have moused up
if( [self hasVerticalScroller] )
{
[[self verticalScroller] mouseUp:currentEvent];
}
if( [self hasHorizontalScroller] )
{
[[self horizontalScroller] mouseUp:currentEvent];
}
return self;
}
return [super hitTest:aPoint];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment