sjordi 39 Posted April 21, 2022 Hi In a TListView, is there a way to know whether we clicked the checkmark (accessory in a dynamicappearance) ? The OnClickItem is fired when we click anywhere in the List Item. Under VCL there were a GetItemAt(X,Y) function to test whether we were on the check mark itself or not. It doesn't exist in FMX. I'd like to be able to put my own icon as a checkmark and turn it on / off only when clicking (or tapping with the finger) only in that checkmark area, not by clicking/tapping the full item itself. Any way to achieve such a thing? Thanks for any idea Steve Share this post Link to post
sjordi 39 Posted April 21, 2022 It looks like you can get the ClickEX event and get the coordinates of the click. Then check wether your clicked within your checkmark area and then respond accordingly. Something like this, say my glyph working as a checkmark is 44x44 and positioned at 0,0 and called "CheckIcon" procedure TForm.myListViewItemClickEx(const Sender: TObject; ItemIndex: Integer; const LocalClickPos: TPointF; const ItemObject: TListItemDrawable); if (LocalClickPos.X >0) AND (LocalClickPos.X < 44) And (LocalClickPos.Y >0) AND (LocalClickPos.Y < 44) then if myListViewItem.Items[ItemIndex].Data['CheckIcon'].AsInteger = 0 then myListViewItemItems[ItemIndex].Data['CheckIcon'] := 0 // First image in the ImageList else myListViewItem.Items[ItemIndex].Data['CheckIcon'] := 1 ; // 2nd image in the ImageList Now this seems to work on Windows, Mac, iOS, Android and Linux. Obviously that's one way to proceed. No problems with screen density differences. But if someone has a better practice, it would be great to post it here for everyone. Steve Share this post Link to post
Serge_G 87 Posted April 22, 2022 Ha, sorry to miss this one yesterday (still in Yeu). I wrote something like that in my blog, in a tutorial or in a response in a forum, I don't remember exactly where, only the image I used for demo. But, as I remember, I don't use positions but the ItemObject name Share this post Link to post
sjordi 39 Posted April 22, 2022 Thanks Mr ListView specialist !!! Still in Arles here! It works fine actually, I didn't find any limit so far, but I'll check your blog. I'm always learning a lot from others, and especially from you... My app is fully MVVM and decoupled mostly from the GUI so trying other implementations rarely break anything. I checked your demos and found a lot of ListView customization, but didn't find one that check/unchecks when only the checkmark is clicked (unless you display it in edit mode but then it's not a custom checkmark) Share this post Link to post
Serge_G 87 Posted April 22, 2022 6 hours ago, sjordi said: Thanks Mr ListView specialist Not so, but I try to be 😉 6 hours ago, sjordi said: Still in Arles here! And did you finally find the Arlésienne 6 hours ago, sjordi said: I checked your demos and found a lot of ListView customization, Yes, I don't remember where I was confronted to that checkbox. I think it was a question in www.developpez.net/forums and don't report it to my blog 6 hours ago, sjordi said: but didn't find one that check/unchecks when only the checkmark is clicked Ah finally, I see where https://www.developpez.net/forums/blogs/138527-sergiomaster/b8177/fmx-selection-delements-tlistview/ I.3 part The mayor part is here, but I skipped the OnclickEx part (sorry) Share this post Link to post
sjordi 39 Posted April 25, 2022 Nope, didn't find the Arlésienne 🙂 It looks like the OnclickEx part works fine as it also allows to react to a click on the item (outside of the checkbox). I'm moving forward with this for now, but can definitely refactor later on. I had your blog article in my personal ressource wiki and didn't see it ... (no comments) Share this post Link to post