Hi,
I'm developing the app which has input fields and whenever user enters the controll, extra panel is being generated with the buttons.
The buttons have captions representing special symbols like degree, greek symbols.
When the button is pressed, corresponding special character should be added to the input fields TEdit existing text.
There are many input fields on the form. So on each OnEnter event of the TEdit it generates the special symbol selection panel, and OnExit event will Free the panel.
I want to somehow tell a button which TEdit he should add the symbol to, when he is pressed.
procedure TForm1.SpecSimboliai(Parent: TWinControl; Edit: TEdit);
var
pSpec: TPanel;
oClose: TPanelEx;
sTekstas: TLabel;
oButton: TPanelEx;
begin
pSpec := TPanel.Create(Self);
pSpec.Parent := Parent;
pSpec.Align := alBottom;
pSpec.Height := 38;
pSpec.Name := 'spec';
pSpec.Caption := '';
pSpec.ParentBackground := false;
sTekstas := TLabel.Create(Self);
sTekstas.Parent := pSpec;
sTekstas.Left := 10;
sTekstas.Top := 12;
sTekstas.Caption := 'Specialūs simboliai:';
oClose := TPanelEx.Create(Self);
oClose.Parent := pSpec;
...
oClose.Top := 2;
oClose.Anchors := [akTop,akRight];
oClose.OnClick := UzdarytiSpec;
oButton := TPanelEx.Create(Self);
oButton.Parent := pSpec;
oButton.Width := 14;
oButton.Height := 14;
oButton.CenterText := true;
oButton.Caption := #$00B0;
oButton.OnClick := AddSpecSymbol;
... //several other buttons
end;
This procedure is run on TEdit.OnEnter
event which looks like
..InputEnter(Sender: TObject);
begin
SpecSimboliai(TEdit(Sender).Parent,TEdit(Sender));
end;
So the panel, label, close button and the degree sign button is created in the above code.
I want to pass the Edit parameter to a button so he will know what controll he is working with, however, i have no idea how to do it as oButton.OnClick
event only expects one parameter, which is Sender: TObject
.
What i imagine i would want is something like this:
oButton.OnClick := AddSpecSymbol(Edit);
So it would sound like: oButton.OnClick(Sender: TObject)
and AddSpecSymbol(Sender: TObject; Edit: TEdit)
have same parameter Sender which they use when event occurs, but parameter Edit is the extra one which is assigned by hand already and should be used by AddSpecSymbol.
ok, i hope all of what i have written is possible to understand to you, if no, tell me and i'll try to edit.
Thank you