summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2009-11-07 16:11:14 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2009-11-07 16:11:14 +0200
commitdc0e92c0f8cc8b77ae1fdd54fbd603c0152d9c21 (patch)
tree618babc910c92438f692b04821296ea532bd2b45 /src
parentc900922247f7efcf0aba1845235eb7e012e3bcd8 (diff)
downloadfpGUI-dc0e92c0f8cc8b77ae1fdd54fbd603c0152d9c21.tar.xz
Implemented search edit for the Index tab in the main form.
Diffstat (limited to 'src')
-rw-r--r--src/frm_main.pas58
1 files changed, 47 insertions, 11 deletions
diff --git a/src/frm_main.pas b/src/frm_main.pas
index 37d50582..a26e0c72 100644
--- a/src/frm_main.pas
+++ b/src/frm_main.pas
@@ -80,6 +80,7 @@ type
CurrentTopic: TTopic; // so we can get easy access to current topic viewed
procedure RichViewClickLink(Sender: TRichTextView; Link: string);
+ procedure IndexSearchEditKeyPress(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean);
procedure MainFormShow(Sender: TObject);
procedure MainFormDestroy(Sender: TObject);
procedure miFileQuitClicked(Sender: TObject);
@@ -103,6 +104,7 @@ type
procedure lbIndexDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure lbSearchResultsDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure btnSearchClicked(Sender: TObject);
+ procedure IndexSearchEditOnChange(Sender: TObject);
procedure DisplaySelectedSearchResultTopic;
procedure UpdateLocationPanel;
procedure EnableControls;
@@ -224,6 +226,16 @@ begin
end;
+procedure TMainForm.IndexSearchEditKeyPress(Sender: TObject; var KeyCode: word;
+ var ShiftState: TShiftState; var Consumed: boolean);
+begin
+ if (KeyCode = keyEnter) or (KeyCode = keyPEnter) then
+ begin
+ Consumed := True;
+ DisplaySelectedIndexTopic;
+ end;
+end;
+
procedure TMainForm.MainFormShow(Sender: TObject);
begin
bvlBody.Realign;
@@ -481,19 +493,8 @@ begin
end;
procedure TMainForm.btnShowIndex(Sender: TObject);
-//var
-// Count: integer;
-// i: integer;
-// s: TfpgString;
-// f: THelpFile;
begin
DisplaySelectedIndexTopic;
- //f := THelpFile(Files[0]);
- //lbIndex.Items.Clear;
- //for i := 0 to f.Index.Count-1 do
- //
- // lbIndex.Items.AddObject(F.Index.GetTopic(i).Title, f.Topics[i]);
- //lbIndex.Invalidate
end;
procedure TMainForm.btnGoClicked(Sender: TObject);
@@ -571,6 +572,39 @@ begin
DoSearch;
end;
+procedure TMainForm.IndexSearchEditOnChange(Sender: TObject);
+var
+ tmpMatchIndex: longint;
+ tmpSearchText: string;
+ i: longint;
+Begin
+ if InIndexSearch then
+ exit;
+
+ tmpMatchIndex := -1;
+ tmpSearchText := trim(IndexSearchEdit.Text);
+
+ for i := 0 to DisplayedIndex.Count - 1 do
+ begin
+ if StrStartsWithIgnoringCase(DisplayedIndex[i], tmpSearchText) then
+ begin
+ tmpMatchIndex := i;
+ break;
+ end;
+ end;
+
+ if tmpMatchIndex = -1 then
+ exit;
+
+ InIndexSearch:= true;
+
+
+ if lbIndex.FocusItem <> tmpMatchIndex then
+ lbIndex.FocusItem := tmpMatchIndex;
+
+ InIndexSearch:= false;
+end;
+
procedure TMainForm.DisplaySelectedSearchResultTopic;
var
Topic: TTopic;
@@ -1654,6 +1688,8 @@ begin
TabOrder := 2;
Text := '';
FontDesc := '#Edit1';
+ OnChange := @IndexSearchEditOnChange;
+ OnKeyPress :=@IndexSearchEditKeyPress;
end;
tsSearch := TfpgTabSheet.Create(PageControl1);