Thanks again leledumbo for your prompt reply.
Sorry, this one is i think a basic in programming, but it seems i don't know how to make it. Basically the keypress are not posted on the edit entry, another thing is how to know where is the focus entry?
Thanks for your tips, it is much appreciated.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons;
type
{ TForm1 }
TForm1 = class(TForm)
btn2: TBitBtn;
btn3: TBitBtn;
btnEnter: TBitBtn;
btnTab: TBitBtn;
btnEsc: TBitBtn;
btn1: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btnTabClick(Sender: TObject);
procedure btnEscClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: char);
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.btn1Click(Sender: TObject);
var c:char;
begin
c:= '1';
Edit1.SetFocus; //currently hardcoded to be in edit1; enhancement is to know who has the focus when a keypress is done
Form1.Keypress(c); // it doesn't work, it does not post the char in my edit box ;-(
end;
procedure TForm1.btn2Click(Sender: TObject);
var c:char;
begin
c:= '2';
Edit1.SetFocus; //currently hardcoded to be in edit1; enhancement is to know who has the focus when a keypress is done
Form1.Keypress(c); // it doesn't work, it does not post the char in my edit box ;-(
end;
procedure TForm1.btn3Click(Sender: TObject);
var c:char;
begin
c:= '3';
Edit1.SetFocus; //currently hardcoded to be in edit1; enhancement is to know who has the focus when a keypress is done
Form1.Keypress(c); // it doesn't work, it does not post the char in my edit box ;-(
end;
procedure TForm1.btnTabClick(Sender: TObject);
var c:char;
begin
c:=chr(9); // should simulate a tab key
Form1.Keypress(c); //
end;
procedure TForm1.btnEscClick(Sender: TObject);
var c:char;
begin
c:=#27;
Form1.Keypress(c); // this one work; the form close
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
begin
if Key = #27 then close ;
ShowMessage('Key=' + Key); // shows correct as specified on my keypress; but the key is not posted on the edit box
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Edit1.SetFocus;
end;
initialization
{$I unit1.lrs}
end.