Corrected Selection Errors
This commit is contained in:
@@ -184,17 +184,20 @@
|
||||
elementBounds.origin.x += elementOffset.x;
|
||||
elementBounds.origin.y += elementOffset.y;
|
||||
|
||||
// Only the horizontal location is to consider for hit testing
|
||||
elementBounds.size.height = CGFLOAT_MAX;
|
||||
|
||||
id<MPExpressionElement> element = [self.expression elementAtIndex:index];
|
||||
if (NSMouseInRect(point, elementBounds, self.flipped)) {
|
||||
NSPoint pointInElement = NSMakePoint(point.x - elementOffset.x, point.y + elementOffset.y);
|
||||
if ([element isString]) {
|
||||
CTLineRef line = [self lineForElementAtIndex:index];
|
||||
CFRetain(line);
|
||||
CFIndex localIndex = CTLineGetStringIndexForPosition(line, point);
|
||||
CFIndex localIndex = CTLineGetStringIndexForPosition(line, pointInElement);
|
||||
CFRelease(line);
|
||||
return [NSIndexPath indexPathWithIndex:currentPosition+localIndex];
|
||||
} else {
|
||||
NSPoint pointInFunction = NSMakePoint(point.x - elementOffset.x, point.y + elementOffset.y);
|
||||
NSIndexPath *subPath = [[self childLayoutAtIndex:index] indexPathForMousePoint:pointInFunction];
|
||||
NSIndexPath *subPath = [[self childLayoutAtIndex:index] indexPathForMousePoint:pointInElement];
|
||||
if (subPath.length == 1) {
|
||||
// A single index is used to communicate back wether the
|
||||
// selection should be before or after the function.
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
replacementLength:(NSUInteger)replacementLength;
|
||||
- (void)invalidate;
|
||||
|
||||
- (MPLayout *)childLayoutAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
#pragma mark Calculation and Drawing Methods
|
||||
- (CTLineRef)createLineForString:(NSString *)aString;
|
||||
|
||||
|
||||
@@ -127,6 +127,15 @@
|
||||
[self.parent invalidate];
|
||||
}
|
||||
|
||||
- (MPLayout *)childLayoutAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.length == 0) {
|
||||
return self;
|
||||
}
|
||||
MPLayout *child = [self childLayoutAtIndex:indexPath.firstIndex];
|
||||
return [child childLayoutAtIndexPath:[indexPath indexPathByRemovingFirstIndex]];
|
||||
}
|
||||
|
||||
#pragma mark Calculation and Drawing Methods
|
||||
- (CTLineRef)createLineForString:(NSString *)aString
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user