How to find caret position in an NSTextView?

后端 未结 2 1369
萌比男神i
萌比男神i 2020-12-14 22:18

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?

2条回答
  •  心在旅途
    2020-12-14 22:37

    NSInteger insertionPoint = [[[myTextView selectedRanges] objectAtIndex:0] rangeValue].location;
    

提交回复
热议问题