Re: finding the insertion point of an NSTextView
Re: finding the insertion point of an NSTextView
- Subject: Re: finding the insertion point of an NSTextView
- From: Greg Titus <email@hidden>
- Date: Sat, 9 Feb 2002 20:30:56 -0800
On Saturday, February 9, 2002, at 07:46 PM, Jake MacMullin wrote:
I'm trying to write an autocompleter for a cocoa based app - I figured
I'd create a delegate for my NSTextView and write some code in the
textDidChange() method to find some suggestions for the current partial
word. However, I'm stuck before I have even begun. I can't figure out
how to find out what the current partial word is in a NSTextView.
This is how I was planning to approach it:
find out where the insertion point is.
backtrack to the last space.
return an NSRange from that position to the insertion point.
And having an NSRange that points to the last partial word, I could
look up possible words that begin with the partial word. So, is there a
way of finding the location of the insertion point? If not, any
suggestions?
It's the -selectedRange. The range you get back will have a length of
zero if the text view has an insertion point instead of a highlighted
range of characters, and the location is what you are interested in...
Hope this helps,
-Greg
_______________________________________________
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.