A stricter numeric text validator?

H H at h.com
Wed Aug 15 10:11:07 PDT 2007


In article <1DzznD.A.e3V.EOwwGB at brage.sunsite.dk>,
 vadim at wxwidgets.org (Vadim Zeitlin) wrote:

> 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

I really like to have an integer-only text validator. And I also need a 
range (open or closed) quite often. I have written my own validators but 
I prefer to use an "official" one.
BTW: I implemented them as templates because of the various numeric 
types (signed and unsigned, short, long and long long). How did you do 
it? This is also the reason why I did not try to submit them because I 
have not found any real template code in wxWidgets, yet.

Hartwig






More information about the wx-users mailing list