How to enable TextFieldWithAutoCompletion Enter key press
Hi
How to get the Enter key press on TextFieldWithAutoCompletion
When I go through the class I found addKeyListener method. but it is not triggering.
completion.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String query = completion.getText();
executeQuery(mDatabase, query);
}
}
});
Thanks for your time.
Please sign in to leave a comment.
You can create an EnterHandlerDelegate that executes your query, and ensure it works in your editor and only there.
is there any documentation available for that?
Yes, EnterHandlerDelegate methods have javadocs
Hi,
I noticed EnterHandlerDelegate listens enter key pressed within a file but not "TextFieldWithAutoCompletion". Am i missing something?
Thanks,
Muhil
EnterHandlerDelegate's aren't invoked in single-line editors
Thank you Peter, It works fine.
I added my CustomEnterHandlerDelegate as an extension, I return "Result.continue" if i do not receive enter key signal from my popup. Should I use Result.default?
I should not impact any other plugin.
When your handler-delegate doesn't do anything, it should return "continue". If it did, then most likely "stop", but sometimes other results also make sense.