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.

0
7 comments
Official 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?

0

Yes, EnterHandlerDelegate methods have javadocs

0

Hi,

I noticed EnterHandlerDelegate listens enter key pressed within a file but not "TextFieldWithAutoCompletion". Am i missing something?

 

Thanks, 

Muhil

0

EnterHandlerDelegate's aren't invoked in single-line editors

0

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.  

0

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.

0

Please sign in to leave a comment.