A stricter numeric text validator?
Yoav Gonen
YoavG at HumanEyes.com
Thu Jul 26 10:16:50 PDT 2007
Hi wx-ers,
I'd like my text controls to have a strict numeric validation: they
should only accept digits, the decimal point (according to the locale)
and a plus and minus sign. The wxTextValidator with wxFILTER_NUMERIC is
not enough: it allows "." and "," (one of which may not be the decimal
point character) and it allows "e" and "E". So I see two options:
1) Derive a validator from wxTextValidator and implement OnChar, where
characters will be filtered;
2) Change wxTextValidator itself, either a) by adding something like
wxFILTER_NUMERIC_STRICT (which will be similar to wxFILTER_NUMERIC
except it will filter out more characters), or b) by adding boolean
flags such as "ALLOW_SCIENTIFIC_NOTATION" and "LOCALE_AWARE".
What do you think? The question is, basically, do you think other people
will also need this validation scheme? If not, I'll keep it in my own
derived validator class.
Actually, my colleague already implemented a wxNumericTextValidator with
the following features:
- It can ensure the text is integer-only or floating point
- It can validate the value is within a given range
If you think this will be of value to others, we will be happy to make
the necessary changes and submit it.
Thanks,
Yoav
More information about the wx-users
mailing list