I'm trying to figure out how to create an autocomplete NSTextView. The idea I'm trying to implement is have an NSPopover display a list of possible usernames, like this: http://cl.ly/McZ0. The goal of it is to function just like Tweetbot for Mac's, the more you type in, the more it filters down the list. I've looked into both
- (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
and
- (NSArray *)completionsForPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index for the autocompletion.
I've learned neither of them apply to what Im trying to do so I looked into
- (void)textDidChange:(NSNotification *)notification
and
- (void)controlTextDidChange:(NSNotification *)notification
I think I'll have to find the point where the "@" is and use the characters after the "@" to filter down the list. What I'm really stuck on is presenting the NSPopover underneath the word in the NSTextView. Anyone have any ideas on how to accomplish this?