Unfortunately the GTextField does not support filtered input.
I assume that you want to be able to enter floating point numbers so simply filtering on
0123456789.-+ would not be enough because the number has structure so it could start with any of these characters but then if the first character is -+ then the next character must be one of
0123456789. if the first numeric character is 0 then it should be followed by the decimal point but the decimal point can only be included once and so on
It is possible to check whether a String is a valid using the following code
- // s is a String and f = float
- try {
- f = Float.parseFloat(s);
- }
- catch (Exception excp) {
- // if you get here s is not a valid float
- }
So you could test the value entered into a GTextField that might be a start.