TextBox上的GWT输入事件 [英] GWT input event on TextBox
问题描述
给出以下代码:
TextBox tb = new TextBox();
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
Window.alert(event.getValue());
}
});
如果TextBox
失去焦点,则会调用
onValueChange
.每当输入值更改时,我都试图调用它.我已阅读的所有解决方案都涉及处理键盘输入和粘贴事件,例如此答案. 如何在GWT中构建Facebook风格的输入框这不是GWT 2.5.1中的地址吗?有没有办法绑定到本机输入更改方法?如果具有此功能,则可以使用其他小部件或使用UI框架
onValueChange
will be called if the TextBox
loses focus. I am trying to have it called whenever the input value changes. The solutions I have read all involve handling the keyup and paste events such as in this answer. How to build a Facebook-style input box in GWT Hasn't this been addresses in GWT 2.5.1? Is there a way to bind to the native input change method? Another widget or using the UI framework would be acceptable if they have this functionality
推荐答案
GWT中的唯一方法是绑定到按下/按下并粘贴事件.
The only way in GWT is to bind to the key down/key up and paste events.
请发送补丁程序以添加对输入事件的支持(使用addBitlessDomHandler
): http://www.gwtproject.org/makinggwtbetter.html ,它应该很容易(在DOMImpl
中添加aa case
),并且有很好的机会加入其中(如果发送得足够早,则有很好的机会在GWT 2.6中发布)
Please send a patch to add support for the input event (using addBitlessDomHandler
): http://www.gwtproject.org/makinggwtbetter.html, it should be rather easy (add a acase
in DOMImpl
) and has good chances to make it in (and if sent early enough, would have good chances to ship in GWT 2.6)
这篇关于TextBox上的GWT输入事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!