From 88f54b742faf9d9ee29897e81090b78f385938fd Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Sun, 7 Sep 2014 16:48:18 +0200 Subject: [PATCH] Prepared to implement improved keyboard navigation --- MathPad/MPFunctionLayout.h | 8 ++++++++ MathPad/MPFunctionLayout.m | 9 ++++----- MathPad/MPSumFunctionLayout.m | 12 +++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/MathPad/MPFunctionLayout.h b/MathPad/MPFunctionLayout.h index 769246d..61d9840 100644 --- a/MathPad/MPFunctionLayout.h +++ b/MathPad/MPFunctionLayout.h @@ -37,4 +37,12 @@ - (NSRect)generateBounds; // To be implemented - (void)drawAtPoint:(NSPoint)point; // To be implemented +// Specify the child that is used when the cursor enters the function from the left or right respectively +- (NSUInteger)indexOfLeadingChild; // To be implemented +- (NSUInteger)indexOfTrailingChild; // To be implemented + +// The index of the child before (left) or after (right) the child at @c index. return NSNotFound if there is no child before or after @c index. +- (NSUInteger)indexOfChildBeforeChildAtIndex:(NSUInteger)index; // May be implemented +- (NSUInteger)indexOfChildAfterChildAtIndex:(NSUInteger)index; // May be implemented + @end \ No newline at end of file diff --git a/MathPad/MPFunctionLayout.m b/MathPad/MPFunctionLayout.m index 75d6d9d..da17931 100644 --- a/MathPad/MPFunctionLayout.m +++ b/MathPad/MPFunctionLayout.m @@ -72,15 +72,14 @@ }]; } -#pragma mark Size and Drawing Methods -- (NSRect)generateBounds +- (NSUInteger)indexOfChildBeforeChildAtIndex:(NSUInteger)index { - return NSZeroRect; + return NSNotFound; } -- (void)draw +- (NSUInteger)indexOfChildAfterChildAtIndex:(NSUInteger)index { - + return NSNotFound; } @end diff --git a/MathPad/MPSumFunctionLayout.m b/MathPad/MPSumFunctionLayout.m index b30de11..8f64c47 100644 --- a/MathPad/MPSumFunctionLayout.m +++ b/MathPad/MPSumFunctionLayout.m @@ -23,6 +23,16 @@ return (MPSumFunction *)self.function; } +- (NSUInteger)indexOfLeadingChild +{ + return 2; +} + +- (NSUInteger)indexOfTrailingChild +{ + return 2; +} + - (CTLineRef)line { CTLineRef line = [self lineForPrivateCacheIndex:0 generator:^CTLineRef{ @@ -75,7 +85,7 @@ childBounds.origin.x += childOffset.x; childBounds.origin.y += childOffset.y; if (NSMouseInRect(point, childBounds, self.flipped)) { - NSPoint pointInChild = NSMakePoint(point.x + childOffset.x, point.y + childOffset.y); + NSPoint pointInChild = NSMakePoint(point.x - childOffset.x, point.y - childOffset.y); NSIndexPath *subPath = [childLayout indexPathForMousePoint:pointInChild]; return [subPath indexPathByPreceedingIndex:index]; }