summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2013-03-12 17:08:40 +0000
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2013-03-12 17:08:40 +0000
commit0fc0a1f0e045b20729c0c988f828607e99d11018 (patch)
tree74cede9cc81909810757ca47c577b659de67eed3 /examples
parentd862c66d097d158add48a51955c948d6e18a8b3e (diff)
downloadfpGUI-0fc0a1f0e045b20729c0c988f828607e99d11018.tar.xz
ide: Grid Modification - restore focus row as best we can.
Diffstat (limited to 'examples')
-rw-r--r--examples/apps/ide/src/ideutils.pas18
1 files changed, 14 insertions, 4 deletions
diff --git a/examples/apps/ide/src/ideutils.pas b/examples/apps/ide/src/ideutils.pas
index 8f4f6921..672103f3 100644
--- a/examples/apps/ide/src/ideutils.pas
+++ b/examples/apps/ide/src/ideutils.pas
@@ -72,6 +72,7 @@ uses
,fpg_grid
,fpg_main
,fpg_utils
+ ,dbugintf
;
var
@@ -392,19 +393,28 @@ begin
end;
procedure CheckGridModifyKeyPresses(Sender: TObject; var KeyCode: word;
- var ShiftState: TShiftState; var Consumed: boolean);
+ var ShiftState: TShiftState; var Consumed: boolean);
+var
+ grd: TfpgStringGrid;
+ r: integer;
begin
+ grd := TfpgStringGrid(Sender);
if (KeyCode = keyInsert) and (ssCtrl in ShiftState) then
begin
- TfpgStringGrid(Sender).RowCount := TfpgStringGrid(Sender).RowCount + 1;
+ grd.RowCount := grd.RowCount + 1;
Consumed := True;
Exit;
end
else if (KeyCode = keyDelete) and (ssCtrl in ShiftState) then
begin
- if TfpgStringGrid(Sender).RowCount = 0 then
+ if grd.RowCount = 0 then
Exit;
- TfpgStringGrid(Sender).DeleteRow(TfpgStringGrid(Sender).FocusRow);
+ r := grd.FocusRow;
+ grd.DeleteRow(r);
+ if (grd.RowCount <> 0) and (grd.RowCount > r) then
+ grd.FocusRow := r // focus what was next row
+ else if (grd.RowCount <> 0) and (grd.RowCount <= r) then
+ grd.FocusRow := r-1; // focus what was previous row
Consumed := True;
Exit;
end;