The labels are not required, but were used for testing, as you change from the editbox to the button, the editbox will lose focus, and the button will become focused, thus giving you an issue if using more than one edit box.
The procedure ButtonPressed uses the TAG option to assign the ascii codes for each button pressed to be displayed in the correct edit box, which is obtained from the EditClick procedure. Remember to set the OnClick event for each of the corresponding buttons.
procedure ButtonPressed(Sender: TObject);
var
index :Integer;
result :Integer;
begin
result:=0;
for index:=0 to ControlCount -1 do
begin
if (Controls[index] is TButton) and TButton(Controls[index]).Focused then
result:=index;
end;
Label2.Caption:='Button Active '+Char(TButton(Controls[result]).Tag);
TEdit(Controls[cureditbox]).Text:=TEdit(Controls[cureditbox]).Text+Char(TButton(Controls[result]).Tag);
end;
As the focus will change from the editbox selected to the button being pressed, the following procedure will handle which box will be updated when pressing button. You will need to set the OnClick event for each edit box to point to this procedure.
procedure EditClick(Sender: TObject);
var
loop :integer;
begin
cureditbox:=1;
for loop:=0 to ControlCount -1 do
begin
if (Controls[loop] is TEdit) and TEdit(Controls[loop]).Focused then
cureditbox:=loop;
end;
Label1.Caption:='Edit Box Active '+Char(TEdit(Controls[cureditbox]).Tag+48);
end;
regards
mrmike