TValueListEditor: don't hardcode '=' in r64089 #f7cf091f71

git-svn-id: trunk@64090 -
This commit is contained in:
bart 2020-10-30 09:06:37 +00:00
parent f7cf091f71
commit 93b66ba3ca

View File

@ -1319,7 +1319,7 @@ end;
procedure TValueListEditor.KeyPress(var Key: Char); procedure TValueListEditor.KeyPress(var Key: Char);
begin begin
inherited KeyPress(Key); inherited KeyPress(Key);
if (Key = '=') and (Col = 0) then if (Key = Strings.NameValueSeparator) and (Col = 0) then
begin//move to Value column begin//move to Value column
Key := #0; Key := #0;
//Modified code from TCustomGrid.KeyDown //Modified code from TCustomGrid.KeyDown
@ -1460,6 +1460,7 @@ procedure TValueListEditor.SetCells(ACol, ARow: Integer; const AValue: string);
var var
I: Integer; I: Integer;
Key, KeyValue, Line: string; Key, KeyValue, Line: string;
Sep: Char;
begin begin
if (ARow = 0) and (doColumnTitles in DisplayOptions) then if (ARow = 0) and (doColumnTitles in DisplayOptions) then
begin begin
@ -1470,9 +1471,10 @@ begin
I:=ARow-FixedRows; I:=ARow-FixedRows;
if ACol=0 then if ACol=0 then
begin begin
Sep := Strings.NameValueSeparator;
Key := AValue; Key := AValue;
{ {
A Key can never contain an equal sign ('=') A Key can never contain NameVlaueSeparator (by default an equal sign ('='))
While we disallow typing '=' inside the Key column While we disallow typing '=' inside the Key column
we cannot prevent the user from pasting text that contains a '=' we cannot prevent the user from pasting text that contains a '='
This leads to strange effects since when we insert the Key/Value pair into This leads to strange effects since when we insert the Key/Value pair into
@ -1482,9 +1484,9 @@ begin
the Value cell will become '==' the Value cell will become '=='
Reported on forum: https://forum.lazarus.freepascal.org/index.php?topic=51977.0;topicseen Reported on forum: https://forum.lazarus.freepascal.org/index.php?topic=51977.0;topicseen
} }
if (Pos('=', Key) > 0) then if (Pos(Sep, Key) > 0) then
begin begin
Key := StringReplace(Key, '=', '', [rfReplaceAll]); Key := StringReplace(Key, Sep, '', [rfReplaceAll]);
//update the content of the Column cell //update the content of the Column cell
inherited SetCells(ACol, ARow, Key); inherited SetCells(ACol, ARow, Key);
end; end;