mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 16:29:32 +02:00
ValEdit: fix not updating active cell contents when changing Strings property (Assign, Add, Delete, Set Text, Clear) which
happens when goAlwaysShowEditor is in Options. git-svn-id: trunk@40204 -
This commit is contained in:
parent
32330dbc49
commit
98b1126b93
@ -60,6 +60,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure SetTextStr(const Value: string); override;
|
procedure SetTextStr(const Value: string); override;
|
||||||
procedure InsertItem(Index: Integer; const S: string; AObject: TObject); override;
|
procedure InsertItem(Index: Integer; const S: string; AObject: TObject); override;
|
||||||
|
procedure InsertItem(Index: Integer; const S: string); override;
|
||||||
procedure Put(Index: Integer; const S: String); override;
|
procedure Put(Index: Integer; const S: String); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TValueListEditor);
|
constructor Create(AOwner: TValueListEditor);
|
||||||
@ -354,26 +355,23 @@ end;
|
|||||||
{ TValueListStrings }
|
{ TValueListStrings }
|
||||||
|
|
||||||
procedure TValueListStrings.SetTextStr(const Value: string);
|
procedure TValueListStrings.SetTextStr(const Value: string);
|
||||||
var
|
|
||||||
IsShowingEditor: Boolean;
|
|
||||||
begin
|
begin
|
||||||
with FOwner do begin
|
// ToDo: Assign also ItemProps ???
|
||||||
// Don't show editor while changing values. Edited cell would not be changed.
|
inherited SetTextStr(Value);
|
||||||
IsShowingEditor := goAlwaysShowEditor in Options;
|
|
||||||
Options := Options - [goAlwaysShowEditor];
|
|
||||||
inherited SetTextStr(Value);
|
|
||||||
if IsShowingEditor then
|
|
||||||
Options := Options + [goAlwaysShowEditor];
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListStrings.InsertItem(Index: Integer; const S: string; AObject: TObject);
|
procedure TValueListStrings.InsertItem(Index: Integer; const S: string; AObject: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
IsShowingEditor: Boolean;
|
||||||
begin
|
begin
|
||||||
// ToDo: Check validity of key
|
// ToDo: Check validity of key
|
||||||
|
//debugln('TValueListStrings.InsertItem: Index=',dbgs(index),' S=',S,' AObject=',dbgs(aobject));
|
||||||
Changing;
|
Changing;
|
||||||
|
IsShowingEditor := goAlwaysShowEditor in FOwner.Options;
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options - [goAlwaysShowEditor];
|
||||||
inherited InsertItem(Index, S, AObject);
|
inherited InsertItem(Index, S, AObject);
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options + [goAlwaysShowEditor];
|
||||||
SetLength(FItemProps, Count);
|
SetLength(FItemProps, Count);
|
||||||
for i := Count-2 downto Index do
|
for i := Count-2 downto Index do
|
||||||
FItemProps[i+1] := FItemProps[i];
|
FItemProps[i+1] := FItemProps[i];
|
||||||
@ -381,10 +379,27 @@ begin
|
|||||||
Changed;
|
Changed;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListStrings.Put(Index: Integer; const S: String);
|
procedure TValueListStrings.InsertItem(Index: Integer; const S: string);
|
||||||
|
var
|
||||||
|
IsShowingEditor: Boolean;
|
||||||
begin
|
begin
|
||||||
// ToDo: Check validity of key
|
// ToDo: Check validity of key
|
||||||
|
//debugln('TValueListStrings.InsertItem: Index=',dbgs(index),' S=',S);
|
||||||
|
IsShowingEditor := goAlwaysShowEditor in FOwner.Options;
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options - [goAlwaysShowEditor];
|
||||||
|
inherited InsertItem(Index, S);
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options + [goAlwaysShowEditor];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TValueListStrings.Put(Index: Integer; const S: String);
|
||||||
|
var
|
||||||
|
IsShowingEditor: Boolean;
|
||||||
|
begin
|
||||||
|
// ToDo: Check validity of key
|
||||||
|
IsShowingEditor := goAlwaysShowEditor in FOwner.Options;
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options - [goAlwaysShowEditor];
|
||||||
inherited Put(Index, S);
|
inherited Put(Index, S);
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options + [goAlwaysShowEditor];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TValueListStrings.Create(AOwner: TValueListEditor);
|
constructor TValueListStrings.Create(AOwner: TValueListEditor);
|
||||||
@ -400,28 +415,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListStrings.Assign(Source: TPersistent);
|
procedure TValueListStrings.Assign(Source: TPersistent);
|
||||||
var
|
|
||||||
IsShowingEditor: Boolean;
|
|
||||||
begin
|
begin
|
||||||
with FOwner do begin
|
// ToDo: Assign also ItemProps if Source is TValueListStrings
|
||||||
// Don't show editor while changing values. Edited cell would not be changed.
|
inherited Assign(Source);
|
||||||
IsShowingEditor := goAlwaysShowEditor in Options;
|
|
||||||
Options := Options - [goAlwaysShowEditor];
|
|
||||||
// ToDo: Assign also ItemProps if Source is TValueListStrings
|
|
||||||
inherited Assign(Source);
|
|
||||||
if IsShowingEditor then
|
|
||||||
Options := Options + [goAlwaysShowEditor];
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListStrings.Clear;
|
procedure TValueListStrings.Clear;
|
||||||
var
|
var
|
||||||
i: Integer;
|
IsShowingEditor: Boolean;
|
||||||
begin
|
begin
|
||||||
|
IsShowingEditor := goAlwaysShowEditor in FOwner.Options;
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options - [goAlwaysShowEditor];
|
||||||
inherited Clear;
|
inherited Clear;
|
||||||
for i := 0 to Length(FItemProps)-1 do
|
if IsShowingEditor then FOwner.Options := FOwner.Options + [goAlwaysShowEditor];
|
||||||
FItemProps[i].Free;
|
FreeItemProps;
|
||||||
SetLength(FItemProps, 0);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListStrings.CustomSort(Compare: TStringListSortCompare);
|
procedure TValueListStrings.CustomSort(Compare: TStringListSortCompare);
|
||||||
@ -433,9 +440,13 @@ end;
|
|||||||
procedure TValueListStrings.Delete(Index: Integer);
|
procedure TValueListStrings.Delete(Index: Integer);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
IsShowingEditor: Boolean;
|
||||||
begin
|
begin
|
||||||
Changing;
|
Changing;
|
||||||
|
IsShowingEditor := goAlwaysShowEditor in FOwner.Options;
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options - [goAlwaysShowEditor];
|
||||||
inherited Delete(Index);
|
inherited Delete(Index);
|
||||||
|
if IsShowingEditor then FOwner.Options := FOwner.Options + [goAlwaysShowEditor];
|
||||||
// Delete also ItemProps
|
// Delete also ItemProps
|
||||||
if Index<=Count then begin
|
if Index<=Count then begin
|
||||||
FItemProps[Index].Free;
|
FItemProps[Index].Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user