summaryrefslogtreecommitdiff
path: root/examples/apps/ide
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2013-03-12 16:23:09 +0000
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2013-03-12 16:23:09 +0000
commitd862c66d097d158add48a51955c948d6e18a8b3e (patch)
tree28b7a1fe7504716c4100420b935b5cd80a38e035 /examples/apps/ide
parent545aa0e4047c8f729bda7adad33540351c714f2a (diff)
downloadfpGUI-d862c66d097d158add48a51955c948d6e18a8b3e.tar.xz
ide: Refactored StringGrid modification shortcuts
Now we can reuse that code in other areas of the IDE.
Diffstat (limited to 'examples/apps/ide')
-rw-r--r--examples/apps/ide/src/frm_projectoptions.pas30
-rw-r--r--examples/apps/ide/src/ideutils.pas23
2 files changed, 27 insertions, 26 deletions
diff --git a/examples/apps/ide/src/frm_projectoptions.pas b/examples/apps/ide/src/frm_projectoptions.pas
index 1f70d022..bb6ee5f3 100644
--- a/examples/apps/ide/src/frm_projectoptions.pas
+++ b/examples/apps/ide/src/frm_projectoptions.pas
@@ -213,20 +213,9 @@ end;
procedure TProjectOptionsForm.grdCompilerDirsKeyPressed(Sender: TObject;
var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean);
begin
- if (KeyCode = keyInsert) and (ssCtrl in ShiftState) then
- begin
- TfpgStringGrid(Sender).RowCount := TfpgStringGrid(Sender).RowCount + 1;
- Consumed := True;
- Exit;
- end
- else if (KeyCode = keyDelete) and (ssCtrl in ShiftState) then
- begin
- if TfpgStringGrid(Sender).RowCount = 0 then
- Exit;
- TfpgStringGrid(Sender).DeleteRow(TfpgStringGrid(Sender).FocusRow);
- Consumed := True;
+ CheckGridModifyKeyPresses(Sender, KeyCode, ShiftState, Consumed);
+ if Consumed then
Exit;
- end;
if TfpgStringGrid(Sender).FocusCol < 10 then
begin
@@ -250,20 +239,9 @@ end;
procedure TProjectOptionsForm.grdCompilerMakeOptionsKeyPressed(Sender: TObject;
var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean);
begin
- if (KeyCode = keyInsert) and (ssCtrl in ShiftState) then
- begin
- TfpgStringGrid(Sender).RowCount := TfpgStringGrid(Sender).RowCount + 1;
- Consumed := True;
- Exit;
- end
- else if (KeyCode = keyDelete) and (ssCtrl in ShiftState) then
- begin
- if TfpgStringGrid(Sender).RowCount = 0 then
- Exit;
- TfpgStringGrid(Sender).DeleteRow(TfpgStringGrid(Sender).FocusRow);
- Consumed := True;
+ CheckGridModifyKeyPresses(Sender, KeyCode, ShiftState, Consumed);
+ if Consumed then
Exit;
- end;
if TfpgStringGrid(Sender).FocusCol < 6 then
begin
diff --git a/examples/apps/ide/src/ideutils.pas b/examples/apps/ide/src/ideutils.pas
index f0b54648..8f4f6921 100644
--- a/examples/apps/ide/src/ideutils.pas
+++ b/examples/apps/ide/src/ideutils.pas
@@ -58,6 +58,9 @@ function IsPas(const FileName: string): Boolean;
function IsInc(const FileName: string): Boolean;
function IsProgram(const FileName: string): Boolean;
+{ Handles key shortcuts like Ctrl+Ins or Ctrl+Del to add or remove grid rows.
+ We add this here, so we can reuse it all over in the IDE. }
+procedure CheckGridModifyKeyPresses(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean);
@@ -66,6 +69,7 @@ implementation
uses
fpg_form
,fpg_memo
+ ,fpg_grid
,fpg_main
,fpg_utils
;
@@ -387,6 +391,25 @@ begin
Result := (FileExt = '.LPR') or (FileExt = '.DPR');
end;
+procedure CheckGridModifyKeyPresses(Sender: TObject; var KeyCode: word;
+ var ShiftState: TShiftState; var Consumed: boolean);
+begin
+ if (KeyCode = keyInsert) and (ssCtrl in ShiftState) then
+ begin
+ TfpgStringGrid(Sender).RowCount := TfpgStringGrid(Sender).RowCount + 1;
+ Consumed := True;
+ Exit;
+ end
+ else if (KeyCode = keyDelete) and (ssCtrl in ShiftState) then
+ begin
+ if TfpgStringGrid(Sender).RowCount = 0 then
+ Exit;
+ TfpgStringGrid(Sender).DeleteRow(TfpgStringGrid(Sender).FocusRow);
+ Consumed := True;
+ Exit;
+ end;
+end;
+
initialization
Initialize;