TCustomMaskEdit.ApplyMaskToText function
Applies the edit mask in the control to the specified value.
Declaration
function ApplyMaskToText(Value: TCaption): TCaptionArguments
Value | Value examined and updated in the method. |
Function result
Value after mask literals and space substitution is applied.
Description
ApplyMaskToText is a
TCaption function used to apply
the edit mask in the control to the text specified in
Value. This
method mimics the behavior implemented in Delphi version 3, including:
- Pads the text with blank values if needed when literals are not used in the mask.
- When literals are present in the edit mask, matching literals in the text are located and processed as "segments" with the literal(s) used as delimiters.
Some examples to clarify:
| EditMask | Text to be set | Result |
|---|---|---|
| 99 | 1 | 1_ |
| cc-cc | 1-2 | 1_-2_ |
| !99 | 1 | _1 |
| !cc-cc | 1-2 | _1-_2 |
| cc-cc@cc | 1-2@3 | 1_-2_@3_ |
| cc-cc@cc | 12@3 | 12-__@3_ |
| cc-cc@cc | 123-456@789 | 12-45@78 |
| !cc-cc@cc | 123-456@789 | 23-56@89 |
This feature seems to have been invented for use with dates:
| EditMask | Text to be set | Result |
|---|---|---|
| 99/99/00 | 23/1/2009 | 23/1_/20 if your locale DateSeparator is '/' |
| !99/99/00 | 23/1/2009 | 23/_1/09 if your locale DateSeparator is '/' |
The resulting text will always have the length defined for the TInternalMask type used in the control. The new text value does not have to pass validation.
ApplyMaskToText is called from the SetTextApplyMask when IsMasked contains True (EditMask has a non-zero length).
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
