diff --git a/AppKit/CPBrowser.j b/AppKit/CPBrowser.j index e92a547af..3f0d6b09b 100644 --- a/AppKit/CPBrowser.j +++ b/AppKit/CPBrowser.j @@ -324,10 +324,12 @@ - (unsigned)columnAtPoint:(CGPoint)aPoint { + var adjustedPoint = [_contentView convertPoint:aPoint fromView:self]; + for (var i = 0, count = _tableViews.length; i < count; i++) { var frame = [[_tableViews[i] enclosingScrollView] frame]; - if (CGRectContainsPoint(frame, aPoint)) + if (CGRectContainsPoint(frame, adjustedPoint)) return i; } diff --git a/AppKit/CPClipView.j b/AppKit/CPClipView.j index f1dc67e10..2fa6ce1ad 100644 --- a/AppKit/CPClipView.j +++ b/AppKit/CPClipView.j @@ -190,17 +190,39 @@ - (BOOL)autoscroll:(CPEvent)anEvent { var bounds = [self bounds], - eventLocation = [self convertPoint:[anEvent locationInWindow] fromView:nil]; + location = [self convertPoint:[event locationInWindow] fromView:nil], + superview = [self superview], + deltaX = 0, + deltaY = 0; - if (CPRectContainsPoint(bounds, eventLocation)) + if (CGRectContainsPoint(bounds, location)) return NO; - var newRect = CGRectMakeZero(); + if (![superview isKindOfClass:[CPScrollView class]] || [superview hasVerticalScroller]) + { + if (location.y < CGRectGetMinY(bounds)) + deltaY = CGRectGetMinY(bounds) - location.y; + else if (location.y > CGRectGetMaxY(bounds)) + deltaY = CGRectGetMaxY(bounds) - location.y; + if (deltaY < -bounds.size.height) + deltaY = -bounds.size.height; + if (deltaY > bounds.size.height) + deltaY = bounds.size.height; + } - newRect.origin = eventLocation; - newRect.size = CPSizeMake(10, 10); + if (![superview isKindOfClass:[CPScrollView class]] || [superview hasHorizontalScroller]) + { + if (location.x < CGRectGetMinX(bounds)) + deltaX = CGRectGetMinX(bounds) - location.x; + else if (location.x > CGRectGetMaxX(bounds)) + deltaX = CGRectGetMaxX(bounds) - location.x; + if (deltaX < -bounds.size.width) + deltaX = -bounds.size.width; + if (deltaX > bounds.size.width) + deltaX = bounds.size.width; + } - return [_documentView scrollRectToVisible:newRect]; + return [self scrollToPoint:CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY)]; } @end