LCL, fix hidding editor on losing grid's focus, issue #15787

git-svn-id: trunk@25583 -
This commit is contained in:
jesus 2010-05-22 16:49:07 +00:00
parent fb35fbd33b
commit 83d89e5433
2 changed files with 10 additions and 16 deletions

View File

@ -2334,13 +2334,11 @@ end;
procedure TCustomDBGrid.DoExit;
begin
{$ifdef dbgDBGrid}DebugLn('DBGrid.DoExit INIT');{$Endif}
if not EditorShowing then begin
if ValidDataSet and (dgCancelOnExit in Options) and
InsertCancelable then
begin
FDataLink.DataSet.Cancel;
EditorCancelEditing;
end;
if ValidDataSet and (dgCancelOnExit in Options) and
InsertCancelable then
begin
FDataLink.DataSet.Cancel;
EditingColumn(FEditingColumn, False);
end;
inherited DoExit;
{$ifdef dbgDBGrid}DebugLn('DBGrid.DoExit FIN');{$Endif}

View File

@ -2301,6 +2301,7 @@ begin
FOptions:=AValue;
UpdateSelectionRange;
if goAlwaysShowEditor in Options then begin
SelectEditor;
EditorShow(true);
end else begin
EditorHide;
@ -3994,10 +3995,7 @@ begin
DebugLn('ExternalWindow');
end;
{$endif}
if EditorMode and Editor.CanFocus then
Editor.SetFocus
else
inherited WMSetFocus(Message);
inherited WMSetFocus(Message);
end;
procedure TCustomGrid.WMChar(var message: TLMChar);
@ -5307,7 +5305,7 @@ begin
FIgnoreClick := True;
{$IFDEF dbgGrid}
DbgOut('Mouse was in ', dbgs(FGCache.HotGridZone));
DebugLn('Mouse was in ', dbgs(FGCache.HotGridZone));
{$ENDIF}
FGCache.ClickMouse := Point(X,Y);
@ -5675,9 +5673,6 @@ procedure TCustomGrid.DoEditorHide;
begin
{$ifdef dbgGrid}DebugLn('grid.DoEditorHide [',Editor.ClassName,'] INIT');{$endif}
Editor.Visible:=False;
if HandleAllocated
and ([csLoading,csDesigning,csDestroying]*ComponentState=[]) then
LCLIntf.SetFocus(Handle);
{$ifdef dbgGrid}DebugLn('grid.DoEditorHide [',Editor.ClassName,'] END');{$endif}
end;
procedure TCustomGrid.DoEditorShow;
@ -5689,7 +5684,7 @@ begin
EditorSetValue;
Editor.Parent:=Self;
Editor.Visible:=True;
if Editor.CanFocus then
if Focused and Editor.CanFocus then
Editor.SetFocus;
InvalidateCell(FCol,FRow,True);
{$ifdef dbgGrid}DebugLn('grid.DoEditorShow [',Editor.ClassName,'] END');{$endif}
@ -5783,6 +5778,7 @@ begin
{$IfDef dbgGrid}DebugLn('DoExit - Ext');{$Endif}
if not EditorAlwaysShown then
InvalidateFocused;
ResetEditor;
if FgridState=gsSelecting then begin
if SelectActive then
FSelectActive := False;