GWT制作虚拟键盘

时间:2014-03-18 15:43:02

标签: gwt

我有带键盘按钮的弹出式面板。任务是在按钮单击时在Login popup面板的textfiled中输入文本。 我试图触发按键并按下事件,但它不会在字段中写入文本。

        final KeyButton keyBut = new KeyButton(smallBut.toString(),smButprs.toString(),codeBut,isShift);
        keyBut.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                txtBox.setFocus(true);
                DomEvent.fireNativeEvent(Document.get().createKeyDownEvent(false, false, keyBut.isShiftKeyDown(), false,keyBut.getKeyCode()), txtBox);
                DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, keyBut.isShiftKeyDown(), false,keyBut.getKeyCode()), txtBox);
                DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, keyBut.isShiftKeyDown(), false,keyBut.getKeyCode()), txtBox);
                //DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, keyBut.isShiftKeyDown(), false,68), txtBox);
            }
        });

1 个答案:

答案 0 :(得分:0)

试试这个:

keyBut.addClickHandler(new ClickHandler() {

    @Override
    public void onClick(ClickEvent event) {
        // If this is a button for "a"
        textBox.setValue(textBox.getValue() + "a");
    }

});