TCustomMaskEdit class
The base class for TMaskEdit.
Declaration
TCustomMaskEdit = class(TCustomEdit)Inheritance
Descends from it: TDBEdit TGEEdit TMaskEdit TStringCellEditor
Description
TCustomMaskEdit is a TCustomEdit descendant, and the base class
for
TMaskEdit. TCustomMaskEdit provides an Edit box with masking
features for characters displayed (or hidden) in the control.
Since we want total control over anything that is done to the text in the control, we have to take into consideration the fact that currently we cannot prevent cutting/pasting/clearing or dragging selected text in the control. These operations are handled by the OS, and text is changed before we can prevent it. Not all widgetsets currently handle the messages for cut/paste/clear. Actually, we would like to have a LM_BEFORE_PASTE (etc.) message... If we allow the OS to cut/clear/paste etc. A situation can occur where mask-literals in the control are changed to random characters (which cannot be undone), or text is shorter or larger than the editmask calls for, which again cannot be undone.
So, as a horrible hack, I decided to only allow changing the text if we coded this change ourself. This is done by setting the FChangeAllowed field to True before any write action (in RealSetTextWhileMasked() ). We try to intercept the messages for cut/paste/copy/clear and perform the appropriate actions instead. If this fails, then in TextChanged we check and will see that FChangeAllowed = False and we will undo the changes made.
To make this undo possible, it is necessary to set FCurrentText every time you set the text in the control! This is achieved in RealSetTextWhileMasked() only.
Bart Broersma, January 2009
Properties
EditText | protected | Value entered in the control and obscured / formatted using the EditMask. |
IsMasked | protected | True if a non-empty value has been assigned to EditMask. |
SpaceChar | protected | Contains the value used to represent Space (#32) characters in the control value. |
MaxLength | protected | Indicates the maximum number of characters that can be stored in the value for the control. |
EditMask | protected | Contains the mask characters classes and literals used to format/obscure the value for the control. |
EnableSets | public | Enables or disables use of set notation in the EditMask. |
ValidationErrorMode | public | Indicates the action taken when the control value is invalid for its mask. |
Modified | public | Indicates if the value for the edit control has been changed. |
Methods
WSRegisterClass | protected | Registers the widget set class reference used to create new instances of the control. |
ApplyMaskToText | protected | Applies the edit mask in the control to the specified value. |
CanShowEmulatedTextHint | protected | Indicates if the control can display its Hint or TextHint using the LCL capability layer. |
DisableMask | protected | Saves and disables the edit mask in the control. |
DoValidationError | protected | Performs actions when the control value is invalid for its edit mask. |
RestoreMask | protected | Restores the saved edit mask in the control. |
RealSetText | protected | Sets the value for the Text in the control. |
RealGetText | protected | Gets the value for the Text in the control. |
GetTextWithoutMask | protected | Gets the text value for the control without formatting applied by an edit mask. |
GetTextWithoutSpaceChar | protected | Gets the value for the control without the Space character literal used in the edit mask. |
SetTextApplyMask | protected | Sets the value for the control after applying its edit mask. |
GetEditText | protected | Gets the value for the EditText property. |
SetEditText | protected | Sets the value for the EditText property. |
GetSel | protected | Finds the starting and ending positions for the selection. |
SetSel | protected | Specifies the starting and ending positions for the text selected in the control. |
TextChanged | protected | Performs actions when the value in the Text property has been changed. |
Change | protected | Suppresses the OnChange event when the initial value for the control is assigned. |
SetCharCase | protected | Sets the value in the CharCase property. |
SetMaxLength | protected | Sets the value for the MaxLength property. |
GetMaxLength | protected | Gets the value for the MaxLength property. |
SetNumbersOnly | protected | Sets the value for the NumbersOnly property. |
Loaded | protected | Performs actions when a component has been loaded from the LCL streaming mechanism. |
LMPasteFromClip | protected | LMPasteFromClip is the LCL message method for pasting from the clipboard. |
LMCutToClip | protected | LMCutToClip is the LCL message method for cutting to the clipboard. |
LMClearSel | protected | LMClearSel is the LCL message method for clearing selected items. |
EditCanModify | protected | If True, the Edit box is allowed to modify its contents. |
Reset | protected | Reset returns the edit to its default state with mask appearing in Text box and no string input. |
DoEnter | protected | Performs actions needed when the control is entered. |
DoExit | protected | Performs actions needed when the control is exited. |
KeyDown | protected | Performs actions needed to apply key down messages. |
HandleKeyPress | protected | Handle all keys from KeyPress and Utf8KeyPress. |
KeyPress | protected | Performs actions needed to handle the specified character in the control. |
Utf8KeyPress | protected | Handles a key press with the specified UTF-8 character value. |
MouseUp | protected | Performs actions needed to handle a mouse button up message. |
CheckCursor | protected | Updates the position for the cursor (or caret) when an EditMask is used in the control. |
CutToClipBoard | public | Moves the selected text into the clipboard (removes it from the control). |
PasteFromClipBoard | public | Inserts text from the clipboard at the current position in the control. |
Create | public | Constructor for the class instance. |
Clear | public | Clears the value for the edit control. |
SelectAll | public | Selects all of the text in the masked edit control. |
ValidateEdit | public | Validates the value for the edit control when an EditMask has been specified. |
Events
OnValidationError | public | Event handler signalled when the value for the masked edit control is invalid. |
Inherited
From TCustomEdit (61)
AddHandlerOnChange Alignment AutoSelect AutoSelected AutoSize BorderStyle CalculatePreferredSize CanUndo CaretPos CharCase ChildClassAllowed ClearSelection CMWantSpecialKey CopyToClipboard CreateParams Destroy EchoMode EditingDone EmulatedTextHintStatus FontChanged GetCaretPos GetControlClassDefaultSize GetNumbersOnly GetReadOnly GetSelLength GetSelStart GetSelText GetTextHint HideSelection InitializeWnd KeyUpAfterInterface Layout NumbersOnly OnChange Options ParentColor PasswordChar PopupMenu ReadOnly RemoveAllHandlersOfObject RemoveHandlerOnChange SelLength SelStart SelText SetCaretPos SetEchoMode SetReadOnly SetSelLength SetSelStart SetSelText SetTextHint ShouldAutoAdjust TabOrder TabStop Text TextHint Undo WMChar WMKillFocus WMSetFocus WndProc
From TWinControl (222)
AddControl AdjustClientRect AlignControls AllAutoSized AutoAdjustLayout AutoSizeDelayed AutoSizeDelayedHandle AutoSizeDelayedReport AutoSizePhases BeginUpdateBounds BorderWidth BoundsLockCount BroadCast Brush BrushCreated CachedClientHeight CachedClientWidth CanFocus CanSetFocus CanTab ChangeScale ChildHandlesCreated ChildKey ChildSizing ClientRectNeedsInterfaceUpdate CMBiDiModeChanged CMBorderChanged CMDoubleBufferedChanged CMEnabledChanged CMEnter CMExit CMParentDoubleBufferedChanged CMShowHintChanged CMShowingChanged CMVisibleChanged CNChar CNKeyDown CNKeyUp CNSysKeyDown CNSysKeyUp ContainsControl ControlAtPos ControlCount ControlKeyDown ControlKeyUp Controls ControlsAligned CreateBrush CreateDockManager CreateHandle CreateParented CreateParentedControl CreateSubClass CreateWnd CustomAlignInsertBefore CustomAlignPosition DefaultHandler DefWndProc DesignerDeleting DestroyHandle DestroyWnd DialogChar DisableAlign DoAddDockClient DoAdjustClientRectChange DoAlignChildControls DoAllAutoSize DoAutoSize DoChildSizingChange DockClientCount DockClients DockDrop DockManager DockOver DockSite DoConstraintsChange DoDockClientMsg DoDockOver DoDragMsg DoFlipChildren DoFloatMsg DoGetDockCaption DoKeyDownBeforeInterface DoKeyPress DoKeyUpBeforeInterface DoRemainingKeyDown DoRemainingKeyUp DoRemoveDockClient DoSendBoundsToInterface DoSendShowHideToInterface DoSetBounds DoubleBuffered DoUnDock DoUndockClientMsg DoUTF8KeyPress EnableAlign EndUpdateBounds EraseBackground FinalizeWnd FindChildControl FindNextControl FixDesignFontsPPIWithChildren FixupTabList FlipChildren Focused FormEndUpdated GetAdjustedLogicalClientRect GetBorderStyle GetChildren GetChildrenRect GetClientOrigin GetClientRect GetControlIndex GetControlOrigin GetDeviceContext GetDockCaption GetEnumeratorControls GetEnumeratorControlsReverse GetMouseCapture GetParentHandle GetPreferredSizeClientFrame GetSiteInfo GetTabOrderList GetTextLen GetTopParentHandle Handle HandleAllocated HandleNeeded InsertControl IntfGetDropFilesTarget IntfUTF8KeyPress Invalidate InvalidateBoundsRealized InvalidateClientRectCache InvalidatePreferredChildSizes IsClientHeightStored IsClientWidthStored IsControlMouseMsg IsFlipped IsResizing IsSpecialSubControl KeyDownAfterInterface KeyDownBeforeInterface KeyUp KeyUpBeforeInterface LockRealizeBounds MainWndProc NotifyControls OnAlignInsertBefore OnAlignPosition OnDockDrop OnDockOver OnEnter OnExit OnGetDockCaption OnGetSiteInfo OnKeyDown OnKeyPress OnKeyUp OnUnDock OnUTF8KeyPress PaintControls PaintHandler PaintTo PaintWindow ParentDoubleBuffered ParentFormHandleInitialized ParentHandlesAllocated ParentWindow PerformTab ReAlign RealizeBounds RealizeBoundsRecursive ReloadDockedControl RemoveControl RemoveFocus Repaint ScaleBy ScaleControls ScrollBy ScrollBy_WS SelectFirst SelectNext SendDialogChar SendMoveSizeMessages SetBorderStyle SetBounds SetChildZPosition SetColor SetControlIndex SetDockManager SetFocus SetShape SetTempCursor ShowControl Showing UnlockRealizeBounds Update UpdateControlState UpdateDockCaption UpdateShowing UseDockManager VisibleDockClientCount WindowHandle WMContextMenu WMDestroy WMEnter WMEraseBkgnd WMExit WMKeyDown WMKeyUp WMMove WMNotify WMPaint WMShowWindow WMSize WMSysChar WMSysKeyDown WMSysKeyUp WMWindowPosChanged WriteLayoutDebugReport WSSetText
From TControl (357)
AccessibleDescription AccessibleName AccessibleRole AccessibleValue Action ActionChange ActionLink ActiveDefaultControlChanged AddHandler AddHandlerOnBeforeDestruction AddHandlerOnChangeBounds AddHandlerOnEnabledChanged AddHandlerOnEnabledChanging AddHandlerOnKeyDown AddHandlerOnMouseWheel AddHandlerOnResize AddHandlerOnVisibleChanged AddHandlerOnVisibleChanging AdjustSize Align AnchorAsAlign AnchorClient AnchoredControlCount AnchoredControls AnchorHorizontalCenterTo AnchorParallel Anchors AnchorSame AnchorSide AnchorSideBottom AnchorSideChanged AnchorSideLeft AnchorSideRight AnchorSideTop AnchorToCompanion AnchorToNeighbour AnchorVerticalCenterTo AssignTo AutoSizing AutoSizingAll AutoSizingLockCount BaseBounds BaseParentClientSize BeforeDestruction BeforeDragStart BeginAutoDrag BeginAutoSizing BeginDrag BiDiMode BorderSpacing BoundsChanged BoundsRect BoundsRectForNewParent BringToFront CalculateDockSizes CanAutoSize Caption CaptureChanged CaptureMouseButtons ChangeBounds Changed CheckChildClassAllowed CheckNewParent CheckOnChangeBounds Click ClientHeight ClientOrigin ClientRect ClientToParent ClientToScreen ClientWidth CMChanged CMCursorChanged CMHintShow CMHitTest CMMouseEnter CMMouseLeave CMParentBiDiModeChanged CMParentColorChanged CMParentFontChanged CMParentShowHintChanged CMSysFontChanged CMTextChanged CNPreferredSizeChanged Color ColorIsStored ConstrainedResize Constraints ControlFontClass ControlOrigin ControlState ControlStyle ControlToScreen CreateAccessibleObject CreateControlBorderSpacing CreateFloatingDockSite Cursor DblClick DefineProperties DesktopFont DisableAutoSizing DoAutoAdjustLayout DoBorderSpacingChange DoCallKeyEventHandler DoCallMouseWheelEventHandler DoCallNotifyHandler Dock Docked DockOrientation DockTrackNoTarget DoContextPopup DoDock DoEndDock DoEndDrag DoFixDesignFontPPI DoMouseDown DoMouseUp DoMouseWheel DoMouseWheelDown DoMouseWheelHorz DoMouseWheelLeft DoMouseWheelRight DoMouseWheelUp DoOnChangeBounds DoOnParentHandleDestruction DoOnResize DoOnShowHint DoScaleFontPPI DoStartDock DoStartDrag DragCanceled DragCursor DragDrop Dragging DragKind DragMode DragOver EnableAutoSizing Enabled EnabledChanged EnabledChanging EndAutoSizing EndDrag ExecuteCancelAction ExecuteDefaultAction FindSubComponent FixDesignFontsPPI Floating FloatingDockSiteClass Font ForeignAnchorSideChanged FormIsUpdating GetAccessibleObject GetAction GetActionLinkClass GetAnchorsDependingOnParent GetCachedText GetCanvasScaleFactor GetChildAccessibleObjectAtPos GetClientScrollOffset GetColorResolvingParent GetCursor GetDefaultColor GetDefaultDockCaption GetDefaultHeight GetDefaultWidth GetDockEdge GetDragImages GetEnabled GetFloating GetFloatingDockSiteClass GetLogicalClientRect GetMousePosFromMessage GetPalette GetParentBackground GetParentComponent GetPopupMenu GetPreferredSize GetRGBColorResolvingParent GetScrolledClientRect GetSelectedChildAccessibleObject GetSidePosition GetTextBuf GetTopParent HandleObjectShouldBeVisible HasHelp HasParent Height HeightIsAnchored HelpContext HelpKeyword HelpType Hide Hint HostDockSite InitiateAction InvalidateControl InvalidatePreferredSize IsAParentAligning IsBorderSpacingInnerBorderStored IsCaptionStored IsControl IsControlVisible IsEnabled IsParentColor IsParentFont IsParentOf IsProcessingPaintMsg IsRightToLeft IsVisible Left LMCaptureChanged LoadedAll LRDockWidth ManualDock ManualFloat MouseCapture MouseDown MouseEnter MouseInClient MouseLeave MouseMove Notification OnChangeBounds OnClick OnConstrainedResize OnContextPopup OnDblClick OnDragDrop OnDragOver OnEditingDone OnEndDock OnEndDrag OnMouseDown OnMouseEnter OnMouseLeave OnMouseMove OnMouseUp OnMouseWheel OnMouseWheelDown OnMouseWheelHorz OnMouseWheelLeft OnMouseWheelRight OnMouseWheelUp OnQuadClick OnResize OnShowHint OnStartDock OnStartDrag OnTripleClick Parent ParentBackground ParentBiDiMode ParentDestroyingHandle ParentFont ParentFontChanged ParentShowHint ParentToClient Perform PositionDockRect QuadClick ReadBounds ReadState Refresh RemoveHandler RemoveHandlerOnBeforeDestruction RemoveHandlerOnChangeBounds RemoveHandlerOnEnabledChanged RemoveHandlerOnEnabledChanging RemoveHandlerOnKeyDown RemoveHandlerOnMouseWheel RemoveHandlerOnResize RemoveHandlerOnVisibleChanged RemoveHandlerOnVisibleChanging ReplaceDockedControl RequestAlign Resize Scale96ToFont Scale96ToForm Scale96ToScreen ScaleConstraints ScaleDesignToForm ScaleFontsPPI ScaleFontTo96 ScaleFontToScreen ScaleFormTo96 ScaleFormToDesign ScaleScreenTo96 ScaleScreenToFont ScreenToClient ScreenToControl SendToBack SessionProperties SetAction SetAlign SetAnchors SetAutoSize SetBiDiMode SetBoundsKeepBase SetCursor SetDragMode SetEnabled SetHint SetInitialBounds SetName SetParent SetParentBackground SetParentBiDiMode SetParentComponent SetTextBuf SetVisible SetZOrder Show ShowHelp ShowHint TBDockHeight Top TripleClick UndockHeight UndockWidth UpdateAnchorRules UpdateBaseBounds UpdateMouseCursor UpdateRolesForForm UseRightToLeftAlignment UseRightToLeftReading UseRightToLeftScrollBar Visible VisibleChanged VisibleChanging Width WidthIsAnchored WindowProc WMCancelMode WMLButtonDBLCLK WMLButtonDown WMLButtonQuadCLK WMLButtonTripleCLK WMLButtonUp WMMButtonDBLCLK WMMButtonDown WMMButtonQuadCLK WMMButtonTripleCLK WMMButtonUp WMMouseHWheel WMMouseMove WMMouseWheel WMRButtonDBLCLK WMRButtonDown WMRButtonQuadCLK WMRButtonTripleCLK WMRButtonUp WMXButtonDBLCLK WMXButtonDown WMXButtonQuadCLK WMXButtonTripleCLK WMXButtonUp
From TLCLComponent (6)
DecLCLRefCount GetWSComponentClass IncLCLRefCount LCLRefCount NewInstance WidgetSetClass
From TComponent (64)
_AddRef _Release CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetTypeInfo GetTypeInfoCount iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetChildOrder SetDesigning SetDesignInstance SetInline SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState
From TPersistent (4)
Assign FPOAttachObserver FPODetachObserver FPONotifyObservers
From TObject (35)
AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
