Proper way to detect on button click on a Dynamic Listview Appearance

  

My listview is set to dynamic appearance. It has 2 TListItemTextButtons on it. I want to assign a sort of “OnClick” event to each of those buttons on each items.

The thing is Almost every listview items needs a different proc to run on it and I know exactly how to do it. When I normally create a dynamic TButton I can assign a custom proc to it using AnonProc2NotifyEvent from TProc<TObject> to TNotifyEvent.

I’m aware of the OnItemClickEx a normal listview has but it seems a little buggy. Example: lets say Listviewitem has a itemindex of 3 and you as a user click on the button in listviewitem 1 then the button from listviewitem 3 will activate.

Embarcadero Docs says that there’s a OnClick event however I cannot find one: http://docwiki.appmethod.com/appmethod/1.15/libraries/en/FMX.ListView.Types.TListItemTextButton_Events

How can I go about assigning a OnClick for a TListItemTextButton?

Example of what I want to do:

LItem.Objects.FindObjectT<TListItemText>(‘Username’).Text := ‘Some username’;
LItem.Objects.FindObjectT<TListItemText>(‘Info’).Text := ‘Some extra info’;

LItem.Objects.FindObjectT<TListItemTextButton>(‘Kick’).OnClick := AnonProc2NotifyEvent(lvPlayers,
procedure(Sender: TObject)
begin
SendRconCommand(‘removeconnection ‘ + jplayers[‘userid’].AsString);
end);

However this provides a Undeclared Identifier for OnClick.

Comments are closed.