View Full Version : [FNR] NumberField allowing decimals when explicitly disabled

12 Jan 2011, 5:59 PM
GWT Version: 2.1.0
GXT Version: 2.2.1

With a NumberField, I've limited the input to only allow Integers... (as described in the javadoc)

NumberField numberField = new NumberField();

But the problem is the user can still enter decimals.
So I tried the using the setAllowDecimals feature

numberField.setAllowDecimals( false );

But the user can still enter decimals.

After debugging, I found onKeyPress method of SpinnerField was never reaching the allowed keys section of code, and was jumping out early due the decimal character being classed as a "special" key (Key number of 46)

Let me know if you want a more complete example, as per the guidelines.. I just figured this is such a simple bug to explain.

FYI: I found thread where someone had reported a similar problem for GXT 1.x -it may be caused by the same bug?

7 Feb 2011, 2:04 PM
I hate it when people "bump" threads, 5 minutes after posting. But thought this was a fair amount of time to..... *BUMP*

Is this a confirmed bug? I was expecting there to be some feedback by now, saying it will be fixed in 3.x etc.


30 Jun 2011, 8:05 AM
I've had this same problem and ended up overriding the onKeyPress method to specifically check if the character is a '.'. The problem appears to be that the fe.isSpecialKey(getKeyCode(fe.getEvent()) logic doesn't work across all systems (I'm using a Mac)

1 Jul 2011, 2:53 AM
This should be fixed in SVN now as of revision 2410