I have addKeyDownHandler.

Follows model i have used

        this.addKeyDownHandler(new KeyDownHandler() {
            public void onKeyDown(KeyDownEvent event) {
                int teclado = event.getNativeEvent().getKeyCode();
                int limite = 0;
                if (getValorAtual() != null) {
                    limite = getValorAtual().length();
                }
                if ((teclado == KeyCodes.KEY_DELETE)) {
                    getValorAtual().delete(0, limite);
                    clearValor(null);
                    formataConteudo();
                } else if (teclado == KeyCodes.KEY_BACKSPACE) {
                    ((TextBox) event.getSource()).cancelKey();
                    if (limite > 0) {
                        getValorAtual().delete((limite - 1), limite);
                        // senão é negativo, então segue o antigo
                        if (getValorAtual().indexOf("-") < 0) {
                            if (getValorAtual().length() == getScala()) {
                                getValorAtual().insert(0, "0");
                            }
                        } else {
                            if (getValorAtual().length() == getScala()
                                    || getValorAtual().length() == (getScala() + 1)) {
                                getValorAtual().insert(1, "0");
                            }
                            if (getValorAtual().toString()
                                    .equals("-" + zeroDecimal(getScala() + 1))) {
                                getValorAtual().deleteCharAt(0);
                            }
                        }
                    }
                    formataConteudo();
                }
            }
        });


Em 01/02/2017 13:25, Ed escreveu:
GWT 2.8

I have the following code. It is used in a application where the input device is a usb keypad with numbers and # key.

I am trying  to use the # key as deliminator to obtains the numerics from the text box.

Everything works  except the # (Delimiter) key gets placed in the textbox after processing and I do not know how to remove it to prepare for next input.  It needs to be removed because there is no backspace key.

Code snippet follows:

        gameInput.addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                int keycode = event.getCharCode();
                if (keycode == '#') {
                    String gamecode = gameInput.getText();
                   
                    gameInput.clear();
                    gameInput.setText("");

.....

Any help would be appreciated.

Best



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to