Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable case insensitive autocomplete for a NSComboBox?

I've bound the NSComboBox bounded to a data source within interface builder. I correctly get the autocomplete suggestions, when I type something in the NSComboBox.

However the autocomplete is case sensitive, which means I don't get suggestion if the character uses the wrong case.

How can I enable case insensitive autocomplete for a NSComboBox, which is bound to the data source in interface builder ?

Thanks

like image 936
aneuryzm Avatar asked Jan 21 '13 14:01

aneuryzm


1 Answers

You should implement comboBox:completedString: in your NSComboBox Data Source, e.g:

- (NSString *)comboBox:(NSComboBox *)comboBox completedString:(NSString *)partialString
{
    for (NSString dataString in dataSourceArray) {
        if ([[dataString commonPrefixWithString:partialString options:NSCaseInsensitiveSearch] length] == [commonPrefixWithString:partialString length]) {
            return testItem;
        }
    }
    return @"";
}
like image 54
Attila H Avatar answered Nov 07 '22 15:11

Attila H