diff --git a/ChangeLog b/ChangeLog index ca8e66d9f..ce9ce091f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-01 Wolfgang Lux + + * Source/NSTextView.m (-mouseDown:): Add missing conversion from + character indexes to glyph indexes when computing an attachment + cell's frame. + 2011-01-01 Wolfgang Lux * Source/NSLayoutManager.m (attachmentSize): Prevent potential diff --git a/Source/NSTextView.m b/Source/NSTextView.m index b7dbbfc41..c8266b187 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -5239,17 +5239,26 @@ other than copy/paste or dragging. */ if (cell != nil) { NSRect cellFrame; - NSRect lfRect; + NSRect lfRect; + NSUInteger glyphIndex; - lfRect = [_layoutManager lineFragmentRectForGlyphAtIndex: startIndex - effectiveRange: NULL]; - cellFrame.origin = [_layoutManager - locationForGlyphAtIndex: startIndex]; - cellFrame.size = [_layoutManager - attachmentSizeForGlyphAtIndex: startIndex]; + glyphIndex = + [_layoutManager + glyphRangeForCharacterRange: NSMakeRange(startIndex, 1) + actualCharacterRange: NULL].location; + lfRect = + [_layoutManager + lineFragmentRectForGlyphAtIndex: glyphIndex + effectiveRange: NULL]; + cellFrame.origin = + [_layoutManager + locationForGlyphAtIndex: glyphIndex]; + cellFrame.size = + [_layoutManager + attachmentSizeForGlyphAtIndex: glyphIndex]; cellFrame.origin.y -= cellFrame.size.height; - cellFrame.origin.x += lfRect.origin.x; - cellFrame.origin.y += lfRect.origin.y; + cellFrame.origin.x += lfRect.origin.x; + cellFrame.origin.y += lfRect.origin.y; /* TODO: What about the insertion point ? */ if ([cell wantsToTrackMouseForEvent: theEvent