How do I pass an event as a function parameter?

Viewed 2706

I have a form that has a list of useful procedures that I have created, that I often use in every project. I am adding a procedure that makes it simple to add a click-able image over where would be the TAccessory of a TListBoxItem. The procedure intakes the ListBox currently, but I would also need it to intake which procedure to call for the OnClick Event for the image.. Here is my existing code:

function ListBoxAddClick(ListBox:TListBox{assuming I need to add another parameter here!! but what????}):TListBox;
var
  i       : Integer;
  Box     : TListBox;
  BoxItem : TListBoxItem;
  Click   : TImage;
begin
  i := 0;
  Box := ListBox;
  while i <> Box.Items.Count do begin
    BoxItem := Box.ListItems[0];
    BoxItem.Selectable := False;

    Click := Timage.Create(nil);
    Click.Parent := BoxItem;
    Click.Height := BoxItem.Height;
    Click.Width := 50;
    Click.Align  := TAlignLayout.alRight;
    Click.TouchTargetExpansion.Left := -5;
    Click.TouchTargetExpansion.Bottom := -5;
    Click.TouchTargetExpansion.Right := -5;
    Click.TouchTargetExpansion.Top := -5;
    Click.OnClick := // this is where I need help

    i := +1;
  end;
  Result := Box;
end;

The desired procedure would be defined in the form that is calling this function.

1 Answers
Related