Instant value change handler on a GWT textbox

前端 未结 6 1626
清酒与你
清酒与你 2020-12-08 07:25

I would like to update a text field instantly when typing in a GWT TextBox. My problem is that ValueChangeEvent and ChangeEvent handlers only fire when the TextBox loses foc

6条回答
  •  温柔的废话
    2020-12-08 08:04

    Just saw this question. Because I was facing the similar problem. 
    

    Did some hack and it worked for me. You can use KeyUpHandler but use it with additional if block that checks for length of textbox. If length of text box is > 0, do your thing. Ex:

    textBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent keyUpEvent) {
        if (textBox.getText().length() > 0) {
        //do your stuff`enter code here`
    
        }
        }
    

提交回复
热议问题