Hi all,
Attached please find the version 0.0.7rc4 of the masked edit control. After
receiving substantial and invaluable development assistance from Will
Sadkin, I have decided that primary development is basically complete and
now submit the control to the community for testing and approval. After
whatever revisions are required, and some light final refactoring, I will
submit the files to Robin for consideration for inclusion in the next build
of wxPython.
See the changelog at the end of this message for details. Just double-click
the attached .py to run the demo.
Highlights of this version include (really there are too many to do this
justice, but):
1. Tab now moves _inside_ the mask, so you can tab through sections of the
date/date-time controls, from one ss# segment to another, etc. This is nice,
you should really look at the demo.
2. Most of the functionality is now held in a mixin class. This allowed Will
to subclass a masked combo box (awesome) and as an example, an IP address
control. You really have to see these terrific controls in action (the
demo).
3. An enormous amount of documentation now resides within the .py.
4. Comma support in addition to numerous other improvements for numeric
handling.
I really can't thank Will enough for his help. He took my code and moved it
to the next level. As a result, this should be an invaluable tool for anyone
doing database or business oriented development.
<<maskededitV007rc4.zip>>
All input welcome.
Regards,
Jeff Childers
jchilders_98@yahoo.com
Changes from version 0.0.6 include:
## CHANGELOG:
## ====================
## Version 0.0.7
## 1. "-" is a toggle for sign; "+" now changes - signed numerics to
positive.
maskededitV007rc4.zip (36.2 KB)
···
##
## 2. ',' in formatcodes now causes numeric values to be comma-delimited
(e.g.333,333).
##
## 3. New support for selecting text within the control.(thanks Will
Sadkin!)
## Shift-End and Shift-Home now select text as you would expect
## Control-Shift-End selects to the end of the mask string, even if
value not entered.
## Control-A selects all *entered* text, Shift-Control-A selects
everything in the control.
##
## 4. event.Skip() added to onKillFocus to correct remnants when running
in Linux (contributed-
## for some reason I couldn't find the original email but thanks!!!)
##
## 5. All major key-handling code moved to their own methods for easier
subclassing: OnHome,
## OnErase, OnEnd, OnCtrl_X, OnCtrl_A, etc.
##
## 6. Email and autoformat validations corrected using regex provided by
Will Sadkin (thanks!).
##
## (The rest of the changes in this version were done by Will Sadkin with
permission from Jeff...)
##
## 7. New mechanism for replacing default behavior for any given key,
using
## ._SetKeyHandler(keycode, func) now available for easier subclassing
of the control.
##
## 8. Reworked the delete logic, cut, paste and select/replace logic, as
well as some bugs
## with insertion point/selection modification. Changed Ctrl-X to use
standard "cut"
## semantics, erasing the selection, rather than erasing the entire
control.
##
## 9. Added option for an "default value" (ie. the template) for use when
a single fillChar
## is not desired in every position. Added IsDefault() function to
mean "does the value
## equal the template?" and modified .IsEmpty() to mean "do all of the
editable
## positions in the template == the fillChar?"
##
## 10. Extracted mask logic into mixin, so we can have both
wxMaskedTextCtrl and wxMaskedComboBox,
## now included.
##
## 11. wxMaskedComboBox now adds the capability to validate from list of
valid values.
## Example: City validates against list of cities, or zip vs zip code
list.
##
## 12. Fixed oversight in EVT_TEXT handler that prevented the events from
being
## passed to the next handler in the event chain, causing updates to
the
## control to be invisible to the parent code.
##
## 13. Added IPADDR autoformat code, and subclass wxIpAddrCtrl for
controlling tabbing within
## the control, that auto-reformats as you move between cells.
##
## 14. Mask characters [A,a,X,#] can now appear in the format string as
literals, by using '\'.
##
## 15. It is now possible to specify repeating masks, e.g. #{3}-#{3}-#{14}
##
## 16. Fixed major bugs in date validation, due to the fact that
## wxDateTime.ParseDate is too liberal, and will accept any form that
## makes any kind of sense, regardless of the datestyle you specified
## for the control. Unfortunately, the strategy used to fix it only
## works for versions of wxPython post 2.3.3.1, as a C++ assert box
## seems to show up on an invalid date otherwise, instead of a
catchable
## exception.
##
## 17. Enhanced date adjustment to automatically adjust heuristic based on
## current year, making last century/this century determination on
## 2-digit year based on distance between today's year and value;
## if > 50 year separation, assume last century (and don't assume last
## century is 20th.)
##
## 18. Added autoformats and support for including HHMMSS as well as HHMM
for
## date times, and added similar time, and militaray time autoformats.
##
## 19. Enhanced tabbing logic so that tab takes you to the next field if
the
## control is a multi-field control.
##
## 20. Added stub method called whenever the control "changes fields", that
## can be overridden by subclasses (eg. wxIpAddrCtrl.)
##
## 21. Changed a lot of code to be more functionally-oriented so
side-effects
## aren't as problematic when maintaining code and/or adding features.
## Eg: IsValid() now does not have side-effects; it merely reflects the
## validity of the value of the control; to determine validity AND
recolor
## the control, _CheckValid() should be used with a value argument of
None.
## Similarly, made most reformatting function take an optional
candidate value
## rather than just using the current value of the control, and only
## have them change the value of the control if a candidate is not
specified.
## In this way, you can do validation *before* changing the control.
##
## 22. Changed validRequired to mean "disallow chars that result in invalid
## value." (Old meaning now represented by emptyInvalid.) (This was
## possible once I'd made the changes in (19) above.)
##
## 23. Added .SetMaskParameters and .GetMaskParameter methods, so they
## can be set/modified/retrieved after construction. Removed
individual
## parameter setting functions, in favor of this mechanism, so that
## all adjustment of the control based on changing parameter values can
## be handled in one place with unified mechanism.
##
## 24. Did a *lot* of testing and fixing re: numeric values. Added ability
## to type "grouping char" (ie. ',') and validate as appropriate.
##
## 25. Fixed ZIPPLUS4 to allow either 5 or 4, but if > 5 must be 9.
##
## 26. Fixed assumption about "decimal or integer" masks so that they're
only
## made iff there's no validRegex associated with the field. (This
## is so things like zipcodes which look like integers can have more
## restrictive validation (ie. must be 5 digits.)
##
## 27. Added a ton more doc strings to explain use and derivation
requirements
## and did regularization of the naming conventions.
##