TValueListEditor: TValueListStrings.InsertItem: don't hide the editor if we're typing in it

(which happens when we type first character in an empty grid).

git-svn-id: trunk@40522 -
This commit is contained in:
bart 2013-03-09 17:46:10 +00:00
parent cd1ff4f40f
commit 19779223aa

View File

@ -493,17 +493,35 @@ 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; MustHideShowingEditor, EditorHasFocus: Boolean;
WC: TWinControl;
IndexToRow: Integer;
begin begin
// ToDo: Check validity of key // ToDo: Check validity of key
//debugln('TValueListStrings.InsertItem: Index=',dbgs(index),' S=',S,' AObject=',dbgs(aobject)); //debugln('TValueListStrings.InsertItem: Index=',dbgs(index),' S=',S,' AObject=',dbgs(aobject));
FGrid.InvalidateCachedRow; FGrid.InvalidateCachedRow;
IsShowingEditor := goAlwaysShowEditor in FGrid.Options; IndexToRow := Index + FGrid.FixedRows;
if IsShowingEditor then FGrid.Options := FGrid.Options - [goAlwaysShowEditor]; if (FGrid.Editor is TCompositeCellEditor) then
begin
WC := TCompositeCellEditorAccess(FGrid.Editor).GetActiveControl;
if (WC is TCustomEdit) then
EditorHasFocus := TCustomEdit(WC).Focused
else
EditorHasFocus := False;
end
else
EditorHasFocus := Assigned(FGrid.Editor) and FGrid.Editor.Focused;
MustHideShowingEditor := Assigned(FGrid.Editor) and
(goAlwaysShowEditor in FGrid.Options) and
FGrid.Editor.Visible and
(IndexToRow = FGrid.Row) and
//if editor is Focussed, we are editing a cell, so we cannot hide!
(not EditorHasFocus);
if MustHideShowingEditor then FGrid.Options := FGrid.Options - [goAlwaysShowEditor];
inherited InsertItem(Index, S, AObject); inherited InsertItem(Index, S, AObject);
FItemProps.Insert(Index, TItemProp.Create(FGrid)); FItemProps.Insert(Index, TItemProp.Create(FGrid));
//only restore this _after_ FItemProps is updated! //only restore this _after_ FItemProps is updated!
if IsShowingEditor then FGrid.Options := FGrid.Options + [goAlwaysShowEditor]; if MustHideShowingEditor then FGrid.Options := FGrid.Options + [goAlwaysShowEditor];
end; end;
procedure TValueListStrings.InsertItem(Index: Integer; const S: string); procedure TValueListStrings.InsertItem(Index: Integer; const S: string);