[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'MaskEdit' (#lcl)

TCustomMaskEdit.ApplyMaskToText

Applies the edit mask in the control to the specified value.

Declaration

Source position: maskedit.pp line 265

protected function TCustomMaskEdit.ApplyMaskToText(

  Value: TCaption

):TCaption;

Arguments

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:

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

TCustomMaskEdit.IsMasked

  

True if a non-empty value has been assigned to EditMask.

TCustomMaskEdit.EditMask

  

Contains the mask characters classes and literals used to format/obscure the value for the control.

TCustomMaskEdit.SetTextApplyMask

  

Sets the value for the control after applying its edit mask.

TCustomMaskEdit.RealSetText

  

Sets the value for the Text in the control.

TCustomMaskEdit.Loaded

  

Performs actions when a component has been loaded from the LCL streaming mechanism.


Version 4.0 Generated 2025-05-03 Home