NSPopover autocomplete for NSTextView

I am trying to figure out how to create an NSTextView autocomplete. The idea I'm trying to implement is to show NSPopover a list of possible usernames, for example: http://cl.ly/McZ0 . The purpose of this is to work just like Tweetbot for Mac, the more you type, the more it filters the list. I looked through 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 found out that none of these are relevant to what I am trying to do, so I looked through

- (void)textDidChange:(NSNotification *)notification

      

and

- (void)controlTextDidChange:(NSNotification *)notification

      

I guess I'll need to find the dot where the "@" is and use the characters after the "@" to filter the list. What I'm really stuck with is representing the NSPopover under the word in the NSTextView. Anyone have any ideas on how to do this?

+3


source to share





All Articles