-
16 Jun 2008 10:39 AM #1
[CLOSED] KeyListener.componentKeyPress() does not work in FF
[CLOSED] KeyListener.componentKeyPress() does not work in FF
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
-
16 Jun 2008 12:56 PM #2
What does not work? Also, you can call setAutoValidate(true) to validate on each key press.
-
16 Jun 2008 2:26 PM #3
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).
-
16 Jun 2008 2:30 PM #4
-
16 Jun 2008 6:21 PM #5
-
20 Jun 2008 8:52 AM #6
This code works fine in FF:
PHP Code: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);


Reply With Quote