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