From 83d89e5433554164effb54e7b6ae26afdd422c4e Mon Sep 17 00:00:00 2001 From: jesus Date: Sat, 22 May 2010 16:49:07 +0000 Subject: [PATCH] LCL, fix hidding editor on losing grid's focus, issue #15787 git-svn-id: trunk@25583 - --- lcl/dbgrids.pas | 12 +++++------- lcl/grids.pas | 14 +++++--------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index e7b44b2818..1841c020a8 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -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} diff --git a/lcl/grids.pas b/lcl/grids.pas index 93cb8c79c6..5abb46738a 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -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;