Hello, I am learning about Lazarus. I want to catch key up and key down and enter in TEDIT fields to jump to other TEDIT fields.
In the example I have written this for TEDIT2. But, as soon as I go into TEDIT2 and press a key, the programme stops and can only be terminated with CTRL+F2. Can you please give me support?
Here is the example:
unit unit1;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm2 }
TForm2 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
procedure Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
public
end;
var
Form2: TForm2;
implementation
{$R *.lfm}
{ TForm2 }
procedure TForm2.Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin
case key of
38 : Edit1.SetFocus; //hoch
40,13 : Edit3.SetFocus //runter, Enter
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Form2.Close;
end;
end.