PDA

View Full Version : [CLOSED] KeyListener.componentKeyPress() does not work in FF



Kutu
16 Jun 2008, 10:39 AM
Platform: FF v2, OSX 10.5, GWT 1.5 + GXT 1.0B4

Use the FormPanelPage example and modified the NumberField code as follow:

final NumberField number = new NumberField();
number.setFieldLabel("Age");
number.setEmptyText("Enter your age");
number.setAllowBlank(false);
number.setAllowDecimals(false);
number.setAllowNegative(false);
number.setFormat(NumberFormat.getFormat("00"));
number.setMaxLength(2);
number.setMinLength(2);
number.addKeyListener(new KeyListener() {

@Override
public void componentKeyPress(final ComponentEvent event) {
number.validate();
}

});
panel.add(number);

- Steps:
1. Enter 2 digits: won't work
2. Enter 3 digits: work

darrellmeyer
16 Jun 2008, 12:56 PM
What does not work? Also, you can call setAutoValidate(true) to validate on each key press.

Kutu
16 Jun 2008, 2:26 PM
I may have overlooked "setAutoValidate" method.

But the componentKeyPress doesn't behave normally. If you plug in my code to the FormPanelPage example, and try to enter "12" (2 digits) in the NumberField (Age) @ Firefox, the warning message will stay unless you put "123" (3 digits).

I specifically limit the valid range to 2 digits (min-max).

Kutu
16 Jun 2008, 2:30 PM
What does not work? Also, you can call setAutoValidate(true) to validate on each key press.

Does setAutoValidate(true) invoke the Validator as well?

gslender
16 Jun 2008, 6:21 PM
yes it does - but the isvalid bug is still there....http://extjs.com/forum/showthread.php?t=38565

darrellmeyer
20 Jun 2008, 8:52 AM
This code works fine in FF:


final NumberField number = new NumberField();
number.setFieldLabel("Age");
number.setEmptyText("Enter your age");
number.setAllowBlank(false);
number.setAllowDecimals(false);
number.setAllowNegative(false);
number.setAutoValidate(true);
number.setFormat(NumberFormat.getFormat("00"));
number.setMaxLength(2);
number.setMinLength(2);
panel.add(number);