Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTokenField Suggest but don't complete

I feel like this must be a common issue that I'm just struggling to figure out, but I couldn't find anyone else who asked the question so... Basically I have an NSTokenField and when the user begins typing I make a SOAP request and get names that are similar to what they have entered. The issue is my suggestions don't necessarily match what they have typed. For example, I match email and last names, but a persons full name appears in the suggestion array. Since the letters don't match, NSTokenField changes what has already been typed to the first item in the array. Is there a way to turn off autocomplete and just have the suggestion box appear?

like image 630
Phil Avatar asked Feb 24 '11 02:02

Phil


1 Answers

    - (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
{
    *selectedIndex = -1;
    return NSArray;
}

It turns out that I was assigning selectedIndex incorrectly but if you just set it to -1 then nothing is selected.

like image 171
Phil Avatar answered Oct 22 '22 23:10

Phil