manox14 / microemu

Automatically exported from code.google.com/p/microemu
0 stars 0 forks source link

Validation on numeric textfields stops long numbers being allowed #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set up a textfield that can handle 10 numbers
2. Try to enter ten 9s, thats 999999999
3. Observe how it will only allow 9 and not 10 

What is the expected output? What do you see instead?

Expected output is that the textfield will allow ten number 9 digits and not 
only 9.

What version of the product are you using? On what operating system?
Microemu revision 2450 on Win7

Please provide any additional information below.

The fix is very simple, in:
org.microemu.device.InputMethod.java in the method validate() around line 110 
swap Integer.parseInt(text); for Long.parseLong(text);

this allows large numbers to parse and retains functionality. 

fixed code is:

    case TextField.NUMERIC :
              if (text != null && text.length() > 0 && !text.equals("-")) {
                    try { 
                        //Integer.parseInt(text); 
            Long.parseLong(text);// parse a long since nfe can be thrown with some ints!
                    } catch (NumberFormatException e) { 

                        return false;
                    }
                }
                break; 

Original issue reported on code.google.com by gareth.m...@gmail.com on 18 Jan 2011 at 3:52

GoogleCodeExporter commented 9 years ago

Original comment by bar...@gmail.com on 18 Jan 2011 at 4:18

GoogleCodeExporter commented 9 years ago

Original comment by bar...@gmail.com on 25 Jan 2011 at 12:30