Uwe C. Schroeder wrote:
Hi again,
I now dug into the source.
Correct me if I'm wrong, but I think the "invalid coloring" is buggy.
[...]
What I figured in the code the parameter change routine sets
the complete
control to emptyInvalid as soon as one field is set to emptyInvalid:This snippet is in line 1709.
self._emptyInvalid = False
for field in self._fields.values():
if field._emptyInvalid:
self._emptyInvalid = True # if any field is .....
Uwe,
Thanks for the pre-release testing!
This is actually a flaw in the design of the code. It (incorrectly)
assumes that because you can't color the control in sections (ie.
"it's all one color or the other") that the coloring can be governed
by a global setting that can be statically evaluated at "compile" time,
and then tested against the entire value of the control, rather than
the value in each field.
This was actually relatively easy to fix, as validity was already
being (mostly) correctly calculated. Enclosed is a patch
for maskededit.py that I believe properly fixes the problem.
If you concur, let me know, and I will submit it to Robin.
FTR: I don't think what you're trying to do is necessary; that is,
the validation for USZIPPLUS4 already only requires that the 1st
5 digits be placed in the 1st field. By default, empty is ok;
as soon as you type in the 1st field, it requires all 5 digits, but
then the last 4 are optional; but if you type in the 2nd field,
all 4 are then also required. (See the behavior on tab 2 of
the masked edit demo.
Since I can't get this working another question:
Is there a way to set the background color similar to the way I'd do it in
a normal TextCtrl ?
Sure, provided you want no implicit coloring for invalid values,
just set the mask parameter invalidBackgroundColor="White".
Thanks again!
/Will Sadkin
Parlance Corporation
www.nameconnector.com
maskededit.patch3 (4.17 KB)