SOLVED: The position of the insertion point in an NSTextView?
SOLVED: The position of the insertion point in an NSTextView?
- Subject: SOLVED: The position of the insertion point in an NSTextView?
- From: Ondra Cada <email@hidden>
- Date: Wed, 5 May 2004 14:50:05 +0200
Hi all,
On 5.5.2004, at 3:13, Ondra Cada wrote:
>
before I dive into all those containers and layout managers and
>
whatever... is there a simple way to find the screen position of the
>
insertion point for a known NSTextView (which happens to have focus)?
Well, so I've dived. Happens anybody to need that, it seems
NSTextView *tv=...
NSRange rr=[tv selectedRange]; rr.length=0; // interested in the
beginning of a selection
NSTextContainer *tc=[tv textContainer];
NSLayoutManager *lm=[tc layoutManager];
rr=[lm glyphRangeForCharacterRange:rr actualCharacterRange:NULL];
NSRect gr=[lm boundingRectForGlyphRange:rr inTextContainer:tc];
NSPoint insertionPoint=[tv convertPoint:gr.origin toView:nil];
works quite well.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.