LCL: TTreeView: editing when scrolled

git-svn-id: trunk@18356 -
This commit is contained in:
mattias 2009-01-20 14:17:49 +00:00
parent d0c44e6ff9
commit fbdb916c8c

View File

@ -2874,7 +2874,8 @@ begin
Node:=Selected; Node:=Selected;
if (tvsIsEditing in FStates) or (Node=nil) then exit; if (tvsIsEditing in FStates) or (Node=nil) then exit;
if not CanEdit(Node) then exit; if not CanEdit(Node) then exit;
Node.EditText; // make node visible (this will cancel editing, so call this first)
EnsureNodeIsVisible(Node);
Include(FStates,tvsIsEditing); Include(FStates,tvsIsEditing);
if FEditor=nil then begin if FEditor=nil then begin
@ -2882,8 +2883,8 @@ begin
FEditor.OnEditingDone:=@EditorEditingDone; FEditor.OnEditingDone:=@EditorEditingDone;
FEditor.OnKeyDown:=@EditorKeyDown; FEditor.OnKeyDown:=@EditorKeyDown;
end; end;
Node.GetAbsoluteIndex; ARect:=Rect(Node.DisplayTextLeft,Node.Top-ScrolledTop,
ARect:=Rect(Node.DisplayTextLeft,Node.Top,ClientWidth-BorderWidth,Node.Bottom); ClientWidth-BorderWidth,Node.Bottom-ScrolledTop);
FEditor.BoundsRect:=ARect; FEditor.BoundsRect:=ARect;
FEditor.Visible:=true; FEditor.Visible:=true;
FEditor.Parent:=Self; FEditor.Parent:=Self;
@ -4952,8 +4953,13 @@ end;
{ CustomDraw support } { CustomDraw support }
procedure TCustomTreeView.EditorEditingDone(Sender: TObject); procedure TCustomTreeView.EditorEditingDone(Sender: TObject);
var
WasFocused: Boolean;
begin begin
WasFocused:=(FEditor<>nil) and FEditor.Focused;
EndEditing; EndEditing;
if WasFocused then
SetFocus;
end; end;
procedure TCustomTreeView.EditorKeyDown(Sender: TObject; var Key: Word; procedure TCustomTreeView.EditorKeyDown(Sender: TObject; var Key: Word;