Skip to content

Commit

Permalink
Issue #9 Search box cleared on entry
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbannon committed Dec 3, 2017
1 parent 6525c13 commit dfeb374
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 5 additions & 3 deletions tomboy-ng/mainunit.lfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object RTSearch: TRTSearch
Left = 354
Height = 330
Top = 211
Top = 210
Width = 495
Caption = 'RTSearch'
ClientHeight = 330
Expand Down Expand Up @@ -32,7 +32,7 @@ object RTSearch: TRTSearch
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goAutoAddRows, goSmoothScroll]
RowCount = 1
ScrollBars = ssAutoVertical
TabOrder = 1
TabOrder = 0
OnDblClick = StringGrid1DblClick
ColWidths = (
267
Expand All @@ -59,7 +59,9 @@ object RTSearch: TRTSearch
BorderSpacing.Left = 3
BorderSpacing.Right = 1
OnEditingDone = Edit1EditingDone
TabOrder = 0
OnEnter = Edit1Enter
OnExit = Edit1Exit
TabOrder = 1
Text = 'Search'
end
object Label1: TLabel
Expand Down
19 changes: 16 additions & 3 deletions tomboy-ng/mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
handle a note being auto saved. This bug killed the Link button in EditNote
2017/11/29 - check to see if NoteLister is still valid before passing
on updates to a Note's status. If we are quiting, it may not be.
2017/12/03 Added code to clear Search box when it gets focus. Issue #9
}

{$mode objfpc}{$H+}
Expand Down Expand Up @@ -99,6 +100,8 @@ TRTSearch = class(TForm)
procedure ButtonClearSearchClick(Sender: TObject);
procedure ButtonRefreshClick(Sender: TObject);
procedure Edit1EditingDone(Sender: TObject);
procedure Edit1Enter(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
Expand Down Expand Up @@ -275,13 +278,23 @@ procedure TRTSearch.ButtonClearSearchClick(Sender: TObject);

procedure TRTSearch.Edit1EditingDone(Sender: TObject);
begin
if Edit1.Text <> 'Search' then begin
if (Edit1.Text <> 'Search') and (Edit1.Text <> '') then begin
NoteLister.GetNotes(Edit1.Text);
NoteLister.LoadSearchGrid(StringGrid1);
ButtonClearSearch.Enabled := True;
end;
end;

procedure TRTSearch.Edit1Enter(Sender: TObject);
begin
if Edit1.Text = 'Search' then Edit1.Text := '';
end;

procedure TRTSearch.Edit1Exit(Sender: TObject);
begin
if Edit1.Text = '' then Edit1.Text := 'Search';
end;

procedure TRTSearch.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
NoteLister.Free;
Expand Down Expand Up @@ -461,8 +474,8 @@ procedure TRTSearch.TrayMenuAboutClick(Sender: TObject);
var
S1, S2, S3, S4, S5 : string;
begin
S1 := 'This is an Alpha Test of a version of Tomboy Notes'#10;
S2 := 'using Lazarus and FPC. It is not ready for production'#10;
S1 := 'This is v0.1 alpha of tomboy-ng, a rewrite of Tomboy Notes'#10;
S2 := 'using Lazarus and FPC. It is not quite ready for production'#10;
S3 := 'use unless you are very careful and have good backups.'#10;
S5 := '';
{$IFDEF DARWIN}
Expand Down

0 comments on commit dfeb374

Please sign in to comment.