Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSpoint from NSTextView insertion point

I have an NSTextView and require the coordinates of the insertion point to display a view there upon user interaction.

There is a function to get the character index from an NSPoint. I am wondering if there is any easy way to do the opposite?

Thanks for any help!

like image 897
chaimp Avatar asked Aug 24 '09 18:08

chaimp


2 Answers

Sure: [textView firstRectForCharacterRange:[textView selectedRange]];

like image 70
Ken Avatar answered Sep 29 '22 01:09

Ken


You might be able to do it with an NSTextView subclass, overriding -drawInsertionPointInRect:color:turnedOn: to cache the drawing rect and using the center of the rect (or some other interior point).

NB: I haven't tried this.

like image 24
Wevah Avatar answered Sep 27 '22 01:09

Wevah