kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #34345
Re: validators
Hi Wayne,
The primary issue is that they try to do all their validation through OnChar(). As JP mentioned, this leads to problems like typing 0 to start a number. But it also means the only way they have to guarantee a number is to allow only digits, zero-or-one minus sign, and zero-or-one decimal separator. This strategy is completely unsuitable for handling typed-in units, never mind evaluation.
Cheers,
Jeff.
> On 25 Feb 2018, at 22:21, Wayne Stambaugh <stambaughw@xxxxxxxxx> wrote:
>
> Jeff,
>
> I'm not opposed to this solution but I need technical information as to why we should use one solution over another. "Brain dead" is not a technical reason and doesn't really help me make an informed decision. I've used validators for simple edit control validation in the past and they worked just fine so I need something tangible as to why they are unacceptable in this case. I'm not saying I agree or disagree with you, I just need something more to go on.
>
> Cheers,
>
> Wayne
>
> On 02/24/2018 04:18 PM, Jeff Young wrote:
>> I looked in to wxWidget’s validators, and they’re definitely challenged. (Brain-dead might be more accurate.)
>> As part of the units overhaul I’m going to propose making widespread use of the UNIT_BINDER, which is a wrapper for a wxTextEntry/wxStaticText-tuple.
>> As a wrapper it’ll be easy to add evaluation and validation to it, and allow most all other clients to wash their hands of unit display, unit conversion, evaluation, and validation.
>> (We’ll probably want to rename UNIT_BINDER something more generic at that point.)
>> Cheers,
>> Jeff.
>>> On 23 Feb 2018, at 20:10, Wayne Stambaugh <1751315@xxxxxxxxxxxxxxxxxx> wrote:
>>>
>>> @JP,
>>>
>>> Understood but we can always create our own validator derive from the
>>> base wxNumValidator or wxValidator object if wxFloatingPointValidator is
>>> to restrictive. As for the numeric limiting, if you set the limit's to
>>> 0.5 than 0.6 is illegal both as an initial value and as user entered
>>> value so that is just the behavior of the validator which we could also
>>> override in a derived object.
>>>
>>> On 02/23/2018 02:39 PM, jean-pierre charras wrote:
>>>> @Wayne,
>>>>
>>>> I was never impressed by the wxFloatingPointValidator.
>>>>
>>>> AFAIK, for instance, if a minimal value is fixed to 0.5, you cannot enter a value starting by 0 like 0.6 (just because starting a value by 0 is too small)
>>>> You need to enter 1.6 and after change 1.6 to 0.6
>>>>
>>>> But the issue here is different:
>>>> In countries using a comma as separator, we use both the . or the , to enter a floating point value.
>>>> In a dialog, these 2 separators *must be* equivalent when the separator is the comma.
>>>>
>>>> But wxFloatingPointValidator does not accept both separators, only the
>>>> comma.
>>>>
>>>> This is very annoying.
>>>>
>>>> If we want to use a FloatingPointValidator, we need to create our own validator.
>>>> For me wxFloatingPointValidator just does not work in Kicad.
>>>>
>>>
>>> --
>>> You received this bug notification because you are a member of KiCad Bug
>>> Squad, which is subscribed to KiCad.
>>> https://bugs.launchpad.net/bugs/1751315
>>>
>>> Title:
>>> pcbnew: float point separator '.' truncate fractional part (default
>>> separator is ',')
>>>
>>> Status in KiCad:
>>> New
>>>
>>> Bug description:
>>> For example: if set in dialog 'Move exactly' `Move vector X` to 2.5 then number truncated up to 2.
>>> If set 2,5 then number not truncated (OK).
>>> I use the RU locale.
>>>
>>> Application: kicad
>>> Version: 5.0-dev-unknown-997d4de~62~ubuntu17.10.1, release build
>>> Libraries:
>>> wxWidgets 3.0.3
>>> libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 (+libidn2/2.0.2) librtmp/2.3
>>> Platform: Linux 4.13.0-32-generic x86_64, 64 bit, Little endian, wxGTK
>>> Build Info:
>>> wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
>>> Boost: 1.62.0
>>> Curl: 7.55.1
>>> Compiler: GCC 7.2.0 with C++ ABI 1011
>>>
>>> Build settings:
>>> USE_WX_GRAPHICS_CONTEXT=OFF
>>> USE_WX_OVERLAY=OFF
>>> KICAD_SCRIPTING=ON
>>> KICAD_SCRIPTING_MODULES=ON
>>> KICAD_SCRIPTING_WXPYTHON=ON
>>> KICAD_SCRIPTING_ACTION_MENU=ON
>>> BUILD_GITHUB_PLUGIN=ON
>>> KICAD_USE_OCE=ON
>>> KICAD_SPICE=ON
>>>
>>> To manage notifications about this bug go to:
>>> https://bugs.launchpad.net/kicad/+bug/1751315/+subscriptions
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help : https://help.launchpad.net/ListHelp
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
Follow ups
References