diff options
Diffstat (limited to 'examples/apps/ide')
-rw-r--r-- | examples/apps/ide/src/frm_projectoptions.pas | 30 | ||||
-rw-r--r-- | examples/apps/ide/src/ideutils.pas | 23 |
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; |