Skip to content

Commit dfeb374

Browse files
committed
Issue #9 Search box cleared on entry
1 parent 6525c13 commit dfeb374

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

tomboy-ng/mainunit.lfm

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object RTSearch: TRTSearch
22
Left = 354
33
Height = 330
4-
Top = 211
4+
Top = 210
55
Width = 495
66
Caption = 'RTSearch'
77
ClientHeight = 330
@@ -32,7 +32,7 @@ object RTSearch: TRTSearch
3232
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goAutoAddRows, goSmoothScroll]
3333
RowCount = 1
3434
ScrollBars = ssAutoVertical
35-
TabOrder = 1
35+
TabOrder = 0
3636
OnDblClick = StringGrid1DblClick
3737
ColWidths = (
3838
267
@@ -59,7 +59,9 @@ object RTSearch: TRTSearch
5959
BorderSpacing.Left = 3
6060
BorderSpacing.Right = 1
6161
OnEditingDone = Edit1EditingDone
62-
TabOrder = 0
62+
OnEnter = Edit1Enter
63+
OnExit = Edit1Exit
64+
TabOrder = 1
6365
Text = 'Search'
6466
end
6567
object Label1: TLabel

tomboy-ng/mainunit.pas

+16-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
handle a note being auto saved. This bug killed the Link button in EditNote
5353
2017/11/29 - check to see if NoteLister is still valid before passing
5454
on updates to a Note's status. If we are quiting, it may not be.
55+
2017/12/03 Added code to clear Search box when it gets focus. Issue #9
5556
}
5657

5758
{$mode objfpc}{$H+}
@@ -99,6 +100,8 @@ TRTSearch = class(TForm)
99100
procedure ButtonClearSearchClick(Sender: TObject);
100101
procedure ButtonRefreshClick(Sender: TObject);
101102
procedure Edit1EditingDone(Sender: TObject);
103+
procedure Edit1Enter(Sender: TObject);
104+
procedure Edit1Exit(Sender: TObject);
102105
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
103106
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
104107
procedure FormCreate(Sender: TObject);
@@ -275,13 +278,23 @@ procedure TRTSearch.ButtonClearSearchClick(Sender: TObject);
275278

276279
procedure TRTSearch.Edit1EditingDone(Sender: TObject);
277280
begin
278-
if Edit1.Text <> 'Search' then begin
281+
if (Edit1.Text <> 'Search') and (Edit1.Text <> '') then begin
279282
NoteLister.GetNotes(Edit1.Text);
280283
NoteLister.LoadSearchGrid(StringGrid1);
281284
ButtonClearSearch.Enabled := True;
282285
end;
283286
end;
284287

288+
procedure TRTSearch.Edit1Enter(Sender: TObject);
289+
begin
290+
if Edit1.Text = 'Search' then Edit1.Text := '';
291+
end;
292+
293+
procedure TRTSearch.Edit1Exit(Sender: TObject);
294+
begin
295+
if Edit1.Text = '' then Edit1.Text := 'Search';
296+
end;
297+
285298
procedure TRTSearch.FormClose(Sender: TObject; var CloseAction: TCloseAction);
286299
begin
287300
NoteLister.Free;
@@ -461,8 +474,8 @@ procedure TRTSearch.TrayMenuAboutClick(Sender: TObject);
461474
var
462475
S1, S2, S3, S4, S5 : string;
463476
begin
464-
S1 := 'This is an Alpha Test of a version of Tomboy Notes'#10;
465-
S2 := 'using Lazarus and FPC. It is not ready for production'#10;
477+
S1 := 'This is v0.1 alpha of tomboy-ng, a rewrite of Tomboy Notes'#10;
478+
S2 := 'using Lazarus and FPC. It is not quite ready for production'#10;
466479
S3 := 'use unless you are very careful and have good backups.'#10;
467480
S5 := '';
468481
{$IFDEF DARWIN}

0 commit comments

Comments
 (0)