From 05b4e376a73bc0219e347ed21fde774434a73bff Mon Sep 17 00:00:00 2001 From: maxim Date: Tue, 3 May 2016 22:06:42 +0000 Subject: [PATCH] Merged revision(s) 52204 #9a6c33c697, 52206 #16b35167c9 from trunk: MaskEdit: don't remove the mask in FormatMaskText regardless of the "MaskSave" value in the specified EditMask. ........ MaskEdit: do replace SpaceChar with #32 in FormatMaskText. ........ git-svn-id: branches/fixes_1_6@52276 - --- lcl/maskedit.pp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lcl/maskedit.pp b/lcl/maskedit.pp index 8185f40512..563bb044e5 100644 --- a/lcl/maskedit.pp +++ b/lcl/maskedit.pp @@ -226,6 +226,7 @@ const procedure RealSetText(const AValue: TCaption); override; function RealGetText: TCaption; override; Function GetTextWithoutMask(Value: TCaption) : TCaption; + function GetTextWithoutSpaceChar(Value: TCaption) : TCaption; Procedure SetTextApplyMask(Value: TCaption); function GetEditText: string; virtual; procedure SetEditText(const AValue: string); @@ -415,7 +416,9 @@ begin if CME.IsMasked then begin Result := CME.ApplyMaskToText(Value); - Result := CME.GetTextWithoutMask(Result); + //Delphi 7 leaves in the mask regardless of the "MaskSave" value in the specified EditMaske + //but SpaceChar must be replaced by #32 + Result := CME.GetTextWithoutSpaceChar(Result); end else Result := Value; @@ -1559,6 +1562,26 @@ Begin Result := S; End; +{ + Replace al FSPaceChars with #32 + Leave all mask literals in place + Needed by FormatMaskText +} +function TCustomMaskEdit.GetTextWithoutSpaceChar(Value: TCaption): TCaption; +var + i: Integer; +Begin + Result := StringReplace(Value, FSpaceChar, #32, [rfReplaceAll]); + //FSpaceChar can be used as a literal in the mask, so put it back + for i := 1 to FMaskLength do + begin + if IsLiteral(FMask[i]) and (FMask[i] = FSpaceChar) then + begin + SetCodePoint(Result, i, FSpaceChar); + end; + end; +end; + // Respond to Text Changed message procedure TCustomMaskEdit.TextChanged;