Archived
1

Prepared to implement improved keyboard navigation

This commit is contained in:
Kim Wittenburg
2014-09-07 16:48:18 +02:00
parent acd12fcc32
commit 88f54b742f
3 changed files with 23 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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];
}