Grid is not focusing his editor! (a little correction)
Original Reporter info from Mantis: EdyKnopfler
-
Reporter name: Éderson Cássio
Original Reporter info from Mantis: EdyKnopfler
- Reporter name: Éderson Cássio
Description:
When I put a TDBGrid in editing mode and make ".SetFocus", the caret doesn't appear. I found that the internal Editor wasn't receiving the focus if necessary.
I made a simple modification to TCustomGrid.SetFocus:
--- ORIGINAL CODE
procedure TCustomGrid.SetFocus;
var
...
begin
...
inherited SetFocus; // --------------------- this call...
{$IFDEF dbgGrid}
DebugLn('TCustomGrid.SetFocus END');
{$ENDIF}
end;
--- MODIFIED CODE
procedure TCustomGrid.SetFocus;
var
...
begin
...
// ... became this:
if (Editor <> nil) and (Editor.Visible) then
Editor.SetFocus
else
inherited SetFocus;
{$IFDEF dbgGrid}
DebugLn('TCustomGrid.SetFocus END');
{$ENDIF}
end;
Actually the problem was in TCustomGrid.
I have made a little modification so that the editor gets the focus when the grid receive it (I was using dgAlwaysShowEditor).
But, if I clicked on another cell at the same line the focus went to another control in the form.
I found the problem was at DoEditorHide: when the editor has the focus, hiding it would remove the focus from the grid, so let's make the grid the focused control.
The modifications I have made are in DoEditorHide and SetFocus of TCustomGrid. They're commented in the attached file.
Steps to reproduce:
Just do:
DataSet.Edit;
DBGrid.EditorMode := True;
DBGrid.SetFocus;
// Where's the cursor?
Put the grid in editor mode (F2 or EditorMode := True)
Click on another cell at the same line
Mantis conversion info:
- Mantis ID: 24194
- OS: Windows XP
- OS Build: SP3
- Platform: Win32
- Version: 1.0.8
- Fixed in version: 1.1 (SVN)
- Fixed in revision: 40780 (#d6a1f482)
- Target version: 1.2.0
- LazTarget: 1.2