Debian Codegraph @

examples/user_interface/edit_test/code/gameviewmain.pas

raw
1 {
2 Copyright 2016-2023 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Main state. }
17 unit GameViewMain;
18
19 interface
20
21 uses Classes,
22 CastleVectors, CastleUIControls, CastleControls, CastleKeysMouse;
23
24 type
25 TViewMain = class(TCastleView)
26 published
27 { Components designed using CGE editor.
28 These fields will be automatically initialized at Start. }
29 ButtonCopyText: TCastleButton;
30 EditNumbers, Edit1, Edit2: TCastleEdit;
31 private
32 procedure ButtonCopyTextClick(Sender: TObject);
33 public
34 constructor Create(AOwner: TComponent); override;
35 procedure Start; override;
36 end;
37
38 var
39 ViewMain: TViewMain;
40
41 implementation
42
43 constructor TViewMain.Create(AOwner: TComponent);
44 begin
45 inherited;
46 DesignUrl := 'castle-data:/gameviewmain.castle-user-interface';
47 end;
48
49 procedure TViewMain.Start;
50 begin
51 inherited;
52 ButtonCopyText.OnClick := {$ifdef FPC}@{$endif} ButtonCopyTextClick;
53
54 EditNumbers.AllowedChars := ['0'..'9'];
55 EditNumbers.MaxLength := 9;
56 end;
57
58 procedure TViewMain.ButtonCopyTextClick(Sender: TObject);
59 begin
60 Edit2.Text := Edit1.Text;
61 end;
62
63 end.