Merged revision(s) 64741 #20bd46fcf7, 64744 #294a0a98c4, 64755 #3f1bd7f441 from trunk:

TMaskEdit: override SelectAll. Reported on forum: https://forum.lazarus.freepascal.org/index.php/topic,53557.0.html
........
TMaskEdit: after deleting an extended selection, don't select a maskliteral. Reported in https://forum.lazarus.freepascal.org/index.php/topic,53557.0.html
........
TMaskEdit: select first editable character after Reset.
........

git-svn-id: branches/fixes_2_0@64893 -
This commit is contained in:
maxim 2021-03-29 22:36:50 +00:00
parent 674ce565ff
commit 4d2d7125fd
2 changed files with 32 additions and 4 deletions

View File

@ -269,6 +269,7 @@ const
{ Required methods }
constructor Create(TheOwner : TComponent); override;
procedure Clear;
procedure SelectAll; override;
procedure ValidateEdit; virtual;
property Modified: Boolean read GetModified write SetModified;
end;
@ -1313,7 +1314,12 @@ procedure TCustomMaskEdit.DeleteChars(NextChar : Boolean);
begin
if NextChar then
begin//VK_DELETE
if HasSelection then DeleteSelected
if HasSelection then
begin
DeleteSelected;
if IsLiteral(FMask[FCursorPos]) then
SelectNextChar;
end
else
begin
//cannot delete beyond length of string
@ -1328,7 +1334,12 @@ begin
else
begin//VK_BACK
//if selected text > 1 char then delete selection
if HasExtSelection then DeleteSelected
if HasExtSelection then
begin
DeleteSelected;
if IsLiteral(FMask[FCursorPos]) then
SelectNextChar;
end
else
begin
//cannot backspace if we are at beginning of string, or if all chars in front are MaskLiterals
@ -1748,6 +1759,8 @@ begin
if IsMasked and (not ReadOnly) then
begin
RealSetTextWhileMasked(FTextOnEnter);
FCursorPos := FFirstFreePos-1;
SetCursorPos;
end;
end;
@ -2125,7 +2138,22 @@ begin
else Inherited Clear;
end;
procedure TCustomMaskEdit.SelectAll;
var
S: String;
begin
if IsMasked then
begin
S := inherited RealGetText;
if (S <> '') then
begin
SetSelStart(0);
SetSelLength(UTF8Length(S));
end;
end
else
inherited SelectAll;
end;
procedure TCustomMaskEdit.ValidateEdit;
var

View File

@ -805,7 +805,7 @@ type
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Clear;
procedure SelectAll;
procedure SelectAll; virtual;
procedure ClearSelection; virtual;
procedure CopyToClipboard; virtual;
procedure CutToClipboard; virtual;