In Delphi XE8 using a Firemonkey TListView.
I have a ListView with about 5 items in it. Each item has an image within them.
How would one detect when the image is clicked/pressed?.
I've been looking at the procedure:
OnItemClickEx
But I do not understand how to use it. Wasn't sure if this is what I need to use or not.
Any help would be great.
Thanks,
Set Listview item image object properties....
procedure TForm1.OnFormCreate(Sender:TObject)
begin
ListView1.ItemAppearanceObjects.ItemObjects.Image.Align := TListItemAlign.Leading;
ListView1.ItemAppearanceObjects.ItemObjects.Image.VertAlign := TListItemAlign.Center;
ListView1.ItemAppearanceObjects.ItemObjects.Image.PlaceOffset.X := 370;
end;
Then in the ItemClickEx procedure I did the following:
procedure TForm1.ListView1ItemClickEx(const Sender: TObject;
ItemIndex: Integer; const LocalClickPos: TPointF;
const ItemObject: TListItemObject);
begin
if (LocalClickPos.X > ListView1.ItemAppearanceObjects.ItemObjects.Image.PlaceOffset.X) and
(LocalClickPos.X < (ListView1.ItemAppearanceObjects.ItemObjects.Image.PlaceOffset.X + ListView1.ItemAppearanceObjects.ItemObjects.Image.Width)) and
(LocalClickPos.Y > ListView1.ItemAppearanceObjects.ItemObjects.Image.PlaceOffset.Y) and
(LocalClickPos.Y < (ListView1.ItemAppearanceObjects.ItemObjects.Image.PlaceOffset.Y + ListView1.ItemAppearanceObjects.ItemObjects.Image.Height)) then
begin
ShowMessage('Image Pressed!');
end;
end;