1 {
2  ***************************************************************************
3  *                                                                         *
4  *   This source is free software; you can redistribute it and/or modify   *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This code is distributed in the hope that it will be useful, but      *
10  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
12  *   General Public License for more details.                              *
13  *                                                                         *
14  *   A copy of the GNU General Public License is available on the World    *
15  *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
16  *   obtain it by writing to the Free Software Foundation,                 *
17  *   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.   *
18  *                                                                         *
19  ***************************************************************************
20 }
21 unit GotoFrm;
22 
23 {$mode objfpc}{$H+}
24 
25 interface
26 
27 uses
28   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
29   StdCtrls, ExtCtrls, Buttons, LazarusIDEStrConsts, LCLType, ButtonPanel;
30 
31 type
32 
33   { TfrmGoto }
34 
35   TfrmGoto = class(TForm)
36     ButtonPanel1: TButtonPanel;
37     Label1: TLabel;
38     Edit1: TEdit;
39     procedure Edit1Change(Sender: TObject);
40     procedure Edit1KeyPress(Sender: TObject; var Key: char);
41   public
42     constructor Create(AOwner: TComponent); override;
43     procedure DoShow; override;
44   end;
45 
46 implementation
47 
48 {$R *.lfm}
49 
50 { TfrmGoto }
51 
52 procedure TfrmGoto.Edit1KeyPress(Sender: TObject; var Key: char);
53 begin
54   if not (Key in [^C,^V,^X,#8,#13,#27,'0'..'9']) then
55     Key:=#0;
56 end;
57 
58 procedure TfrmGoto.Edit1Change(Sender: TObject);
59 var
60   L: Integer;
61 begin
62   ButtonPanel1.OKButton.Enabled := TryStrToInt(Edit1.Text,L);
63 end;
64 
65 constructor TfrmGoto.Create(AOwner: TComponent);
66 begin
67   inherited Create(AOwner);
68 
69   Caption := lisGotoLine;
70   Label1.Caption := lisUEGotoLine;
71   ButtonPanel1.OKButton.Caption:=lisMenuOk;
72   ButtonPanel1.CancelButton.Caption:=lisCancel;
73   Edit1.Caption := '';
74   Edit1.MaxLength := 10;  //enough for MaxLongInt
75 end;
76 
77 procedure TfrmGoto.DoShow;
78 begin
79   Edit1.SelectAll;
80   Edit1.SetFocus;
81   Edit1Change(nil);
82   inherited DoShow;
83 end;
84 
85 end.
86 
87