Autocomplete popup is not coming in TextFieldWithAutoCompletion

Hi 

I have a TextFieldWithAutoCompletion inflated on JPanel. And I have a collection of variants applied to TextFieldWithAutoCompletion,

TextFieldWithAutoCompletion<String> completion = TextFieldWithAutoCompletion.create(mProject, QuerySuggestionService.getBasicQueryCommandsAsList(), true, "");
completion.setVisible(true);

TextFieldWithAutoCompletionListProvider<String> provider = new TextFieldWithAutoCompletionListProvider<String>(QuerySuggestionService.getBasicQueryCommandsAsList()) {
@NotNull
@Override
protected String getLookupString(@NotNull String s) {
Logger.d(getClass().getSimpleName(), s);
completion.setCaretPosition(completion.getText().length());
return s;
}
};

completion.installProvider(provider);

 

But there is no auto pop-up is coming when I started typing on this completion component.  But getLookupString will trigger each time while typing and whatever the letter I typed It fires the first element in that collection.

I am a noob on this. I didn't find any tutorial or example for this. 

Thanks for your time

0
3 comments
Official comment

getLookupString isn't supposed to have side effects, it's just the string that will be matched against what you type, and then inserted into the editor when you select the item. You can use StringsCompletionProvider instead of your own TextFieldWithAutoCompletionListProvider.

Thanks for your quick reply.

Actually, there is no popup coming when I typed something in Editor. Is there anything I missed?

 

0

TextFieldWithAutoCompletion.StringsCompletionProvider did the trick

Now it is showing the popup with suggestions.

 One more question-

How to make that row customize?. Or I want to add some description to each item like code completion shows return types in the popup. How to do that?

 

 

0

Please sign in to leave a comment.