diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2014-08-09 18:01:57 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2014-08-09 18:06:25 +0100 |
commit | 641f24b2cbccbb3b8c8629f89b1b9d61196ae950 (patch) | |
tree | ad4173f3901d6db44bcd2cff2596d53763713a77 /examples | |
parent | 27f18ffb0223c1f8186e9614083b2bfcb6c4d261 (diff) | |
download | fpGUI-641f24b2cbccbb3b8c8629f89b1b9d61196ae950.tar.xz |
maximus: Adds the ability to remove a unit from the project tree
Simply select the node in the Project tree "Units" list, and press the
DEL key. If you don't save the project, the unit will still be part of
the project (easy undo feature). If you save the project the project
file will be updated - minus that unit.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/apps/ide/src/frm_main.pas | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/apps/ide/src/frm_main.pas b/examples/apps/ide/src/frm_main.pas index 65985631..6391ceba 100644 --- a/examples/apps/ide/src/frm_main.pas +++ b/examples/apps/ide/src/frm_main.pas @@ -118,6 +118,7 @@ type procedure AddUnitToProject(const AUnitName: TfpgString); procedure miProjectAddUnitToProject(Sender: TObject); procedure tvProjectDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint); + procedure tvProjectKeyPressed(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean); procedure grdMessageKeyPressed(Sender: TObject; var KeyCode: Word; var ShiftState: TShiftState; var Consumed: Boolean); procedure TabSheetClosing(Sender: TObject; ATabSheet: TfpgTabSheet); procedure BuildTerminated(Sender: TObject); @@ -587,6 +588,38 @@ begin end; end; +procedure TMainForm.tvProjectKeyPressed(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean); +var + r: TfpgTreeNode; + n: TfpgTreeNode; + i: integer; +begin + if keyCode = keyDelete then + begin + r := GetUnitsNode; + if r.FindSubNode(tvProject.Selection.Text, False) = tvProject.Selection then + begin + // remove from project, then from tree view + n := tvProject.Selection; + tvProject.GotoNextNodeUp; + r.Remove(n); + tvProject.Invalidate; + GProject.UnitList.Remove(TUnit(n.Data)); + + for i := 0 to pcEditor.PageCount-1 do + begin + if pcEditor.Pages[i].TagPointer = n.Data then + begin + pcEditor.Pages[i].TagPointer := nil; + break + end; + end; + TUnit(n.Data).Free; + n.Free; + end; + end; +end; + procedure TMainForm.grdMessageKeyPressed(Sender: TObject; var KeyCode: Word; var ShiftState: TShiftState; var Consumed: Boolean); var cr: TClipboardKeyType; @@ -1478,6 +1511,7 @@ begin Hint := ''; TabOrder := 20; OnDoubleClick := @tvProjectDoubleClick; + OnKeyPress := @tvProjectKeyPressed; end; tsFiles := TfpgTabSheet.Create(pnlTool); |