Re: Coordinate Systems
Re: Coordinate Systems
- Subject: Re: Coordinate Systems
- From: Jérôme Laurens <email@hidden>
- Date: Thu, 10 Oct 2002 15:28:09 +0200
Le jeudi, 10 oct 2002, ` 14:04 Europe/Zurich, Tom Gray a icrit :
>
Hi,
>
>
I am trying to improve my understanding of locationInWindow and
>
characterIndexForPoint. What I am attempting to do is get the index of
>
a character in a NSTextView underneath a mouse click. I using the
>
NSEvent method locationInWindow to get the mouse click location.
>
>
>
1 convert point from window coordinates to text view coord
2 manually convert point to text container coordinates (taking into
account the text container inset and top left origin)
3 use the layout manager
glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:
- (unsigned)glyphIndexForPoint:(NSPoint)aPoint
inTextContainer:(NSTextContainer *)aTextContainer
fractionOfDistanceThroughGlyph:(float *)partialFraction
4 convert the glyph index to a character range using once more the
layout manager
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.