NSTokenField
takes quite a time to propose suggestion to the text I enter.
More precisely, here is what happens:
textDidBeginEditing:
of NSTokenField
is called immediatelytokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:
is called and its execution is very quick.I would like to understand what happens and possibly improve this situation.
My question:
What does happen between textDidBeginEditing:
and tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:
?
EDIT
Very strange: if I type ";" instead of "a", it goes much quicker! even though I did the following:
- (NSArray *) tokenField:(NSTokenField *)tokenField
completionsForSubstring:(NSString *)substring
indexOfToken:(NSInteger)tokenIndex
indexOfSelectedItem:(NSInteger *)selectedIndex
{
return @[@"Hello"];
}
I think it is a bug of OSX 10.9
.
Here is what I did. The screen:
(the textField
is a NSTokenField
)
Then, in a delegate for this NSTokenField
, put the following code
- (NSArray *) tokenField:(NSTokenField *)tokenField
completionsForSubstring:(NSString *)substring
indexOfToken:(NSInteger)tokenIndex
indexOfSelectedItem:(NSInteger *)selectedIndex
{
return @[@"Jojo!!"];
}
- (id) tokenField:(NSTokenField *)tokenField
representedObjectForEditingString:(NSString *)editingString
{
return @"Jojo the cat" ;
}
- (NSString *) tokenField:(NSTokenField *)tokenField
displayStringForRepresentedObject:(id)representedObject
{
return @"Jojo" ;
}
You'll see, it bugs.