Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find caret position in an NSTextView?

I've an NSTextView with with several semi-colon separated strings. I need to find on which of those strings the caret has been placed. How could I do that?

like image 875
ruipacheco Avatar asked Nov 09 '09 13:11

ruipacheco


1 Answers

For Swift 4

let insertionPointIndex = myTextView.selectedRanges.first?.rangeValue.location
like image 156
Jay Mehta Avatar answered Sep 28 '22 01:09

Jay Mehta