I need to print something in the method on every key press event. I have tried the below code and the problem with that is, first key press in always returning null. Whereas, after typing the second letter, it prints the first key event. Key Press event is not capturing the letter on first event. Can you please help in resolving this ?
final StringComboBox searchGridTextBox = new StringComboBox();
searchGridTextBox.setEmptyText("Search Grid");
searchGridTextBox.addFocusHandler(new FocusHandler(){
@Override
public void onFocus(FocusEvent event){
if(searchGridTextBox.getStore().size() > 0)
searchGridTextBox.expand();
}
});
searchGridTextBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
System.out.println("On key press event ") ;
}
});