Skip to content

Commit

Permalink
Search for text view until we run out of window in selectViewAtPositi…
Browse files Browse the repository at this point in the history
…on:relativeTo:.

We start with an offset of 40 in the direction dictated by the
provided position, and then increase in multiples of 40 until
we are no longer over a view at all or we have found a
ViTextView.
  • Loading branch information
Shadowfiend committed Dec 7, 2013
1 parent be011a8 commit 9c02825
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions app/ViWindowController.m
Expand Up @@ -1911,20 +1911,29 @@ - (BOOL)selectViewAtPosition:(ViViewOrderingMode)position relativeTo:(ViViewCont
referencePoint.x = MIN(MAX(referencePoint.x, 10), scrollView.frame.size.width - 10);
referencePoint.y = MIN(MAX(referencePoint.y, 10), scrollView.frame.size.height - 10);

if (position == ViViewUp) {
referencePoint.y = -40;
} else if (position == ViViewDown) {
referencePoint.y = currentViewSize.height + 40;
} else if (position == ViViewLeft) {
referencePoint.x = -80;
} else if (position == ViViewRight) {
referencePoint.x = currentViewSize.width + 80;
}

NSPoint splitViewReferencePoint = [tabController.view.superview convertPoint:referencePoint
fromView:currentView];

hitView = [tabController.view hitTest:splitViewReferencePoint];
NSInteger offsetStep = 40;
NSInteger offsetCount = 0;

do {
offsetCount++;
NSInteger offset = offsetStep * offsetCount;

if (position == ViViewUp) {
referencePoint.y = -1 * offset;
} else if (position == ViViewDown) {
referencePoint.y = currentViewSize.height + offset;
} else if (position == ViViewLeft) {
referencePoint.x = -1 * offset;
} else if (position == ViViewRight) {
referencePoint.x = currentViewSize.width + offset;
}

NSPoint splitViewReferencePoint =
[tabController.view.superview convertPoint:referencePoint
fromView:scrollView];

hitView = [tabController.view hitTest:splitViewReferencePoint];
} while (hitView && ! [hitView isKindOfClass:[ViTextView class]]);
}

ViViewController *otherViewController = nil;
Expand Down

0 comments on commit 9c02825

Please sign in to comment.