NSTokenField Suggest but don't complete
Asked Answered
G

2

5

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?

Gereld answered 24/2, 2011 at 2:58 Comment(0)
G
8
    - (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.

Gereld answered 21/3, 2011 at 22:31 Comment(0)
C
0

In swift the answer is:

if selectedIndex != nil {
    selectedIndex.memory = -1
}
Condescension answered 7/4, 2016 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.