Created
January 13, 2012 19:57
-
-
Save curthard89/1608395 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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