A stricter numeric text validator?

Vadim Zeitlin vadim at wxwidgets.org
Wed Aug 15 06:45:27 PDT 2007


On Thu, 26 Jul 2007 19:16:50 +0200 Yoav Gonen <YoavG at HumanEyes.com> wrote:

YG> I'd like my text controls to have a strict numeric validation: they
YG> should only accept digits, the decimal point (according to the locale)
YG> and a plus and minus sign. The wxTextValidator with wxFILTER_NUMERIC is
YG> not enough: it allows "." and "," (one of which may not be the decimal
YG> point character)

 This should be really just fixed.

YG> and it allows "e" and "E".

 While this merits an option (as you say below).

YG> 2) Change wxTextValidator itself, either a) by adding something like
YG> wxFILTER_NUMERIC_STRICT (which will be similar to wxFILTER_NUMERIC
YG> except it will filter out more characters), or b) by adding boolean
YG> flags such as "ALLOW_SCIENTIFIC_NOTATION" and "LOCALE_AWARE".

 I.e. basically I think it should always be LOCALE_AWARE but have the other
flag.

YG> What do you think? The question is, basically, do you think other people
YG> will also need this validation scheme?

 Making the validator aware of the current locale would be definitely
useful. Disabling the use of scientific notation is less important IMHO.

YG> Actually, my colleague already implemented a wxNumericTextValidator with
YG> the following features:
YG> - It can ensure the text is integer-only or floating point
YG> - It can validate the value is within a given range
YG> If you think this will be of value to others, we will be happy to make
YG> the necessary changes and submit it.

 I have trouble understanding how useful this would be as I don't have much
experience with using validators myself but I think that for people who do
use them extensively such class would be very useful so I'd encourage you
(and/or your colleague) to submit it.

 TIA,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/





More information about the wx-users mailing list