KeyUpHandler 只触发一次

KeyUpHandler firing only once

我正在尝试让 KeyUpHandler 为 TextBox 小部件工作(弹出 TextBox 的值)。在下面的简单实现中,它只触发一次,然后在 firefox 控制台中抛出错误:

uncaught exception: java.lang.AssertionError: Negative entryDepth value at exit -1

我在 eclipse Luna 中使用 运行 作为超级开发模式。 编译时没有错误。

//imports
public class myClass implements EntryPoint {
    private VerticalPanel panel = new VerticalPanel();
    private TextBox box = new TextBox();

    public void onModuleLoad() {
        panel.add(box);
        RootPanel.get("gwtContainer").add(panel);
        box.addKeyUpHandler(new KeyUpHandler() {
            @Override
            public void onKeyUp(KeyUpEvent event) {
                Window.alert(box.getValue());
            }
         });
    }
}

试试这个:

 final TextBox box = new TextBox();
 ...
 box.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            Window.alert(box.getValue());
        }
 });