0

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.

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.

Adriaan
  • 806
  • 7
  • 24
  • Please provide a [reprex]. The simplest form and components structure that demonstrate what you have so far, and what you want to achieve. – Tom Brunberg Aug 07 '19 at 17:23
  • I want to assign a OnClick event for a TListItemTextButton. Emba docs says it has such an event but I cannot seem to access it and only get undeclared Identifier. I editted the question providing the doc link. – Adriaan Aug 07 '19 at 17:26
  • Emba docs also say that the `OnClick` event does not exist anymore (or it is not documented) after Seattle. Which version do you have (is it really AppMethod)? – Tom Brunberg Aug 07 '19 at 18:21
  • I have Rio 10.3.2 Is there anyway around this then? – Adriaan Aug 07 '19 at 18:25
  • I don't know, and I don't want to spend time on trying to create a representative test case. Oh, and the newest version I have installed is Berlin (10.1) – Tom Brunberg Aug 07 '19 at 18:29
  • My bad. I looked at the wrong docs. There is no OnClick for Rio like you mentioned http://docwiki.embarcadero.com/Libraries/Rio/en/FMX.ListView.Types.TListItemTextButton_Events – Adriaan Aug 07 '19 at 18:33
  • So you know the right event is `OnSelect`, and you don't need a separate one for each ListItemTextButton. The `Sender` parameter tells you which one fired the event. – Ken White Aug 07 '19 at 23:58
  • On Select fires even if the list item is selected. No matter what you click on it fires. – Adriaan Aug 08 '19 at 12:42

0 Answers0