sjordi 39 Posted January 12, 2023 (edited) Hi, The TListView component offers just a swipe left to display the Delete button. While it's possible to customize the text with something else, it fires an event only to an Item "swipe left". I'd like to be able to swipe both directions, right and left, in order to check/uncheck (select/unselect) the current item. Any way to easily implement this? Or any available FMX component (even paid) that extends/derives from TListViews? Thanks for any help and suggestion Edited January 12, 2023 by sjordi Share this post Link to post
programmerdelphi2k 237 Posted January 13, 2023 (edited) hi @sjordi FMX: I have tested on "MSWindows - mouse" and "Android 11 - finger" and I can delete the item using "Left or Rigth" direction. Note: if "deleting by code" needs hide the delete button on next item showed on ListView after item-deleted! type TForm1 = class(TForm) ListView1: TListView; GestureManager1: TGestureManager; .... var LastLI: TListItem = nil; // to avoid many times in same item... procedure TForm1.FormCreate(Sender: TObject); begin for var i: integer := 0 to 9 do ListView1.Items.Add.Text := 'Item' + i.ToString; end; procedure TForm1.ListView1Gesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); var LI: TListItem; begin Handled := true; // YOU on control! // //if GestureToIdent(EventInfo.GestureID, s) then Memo1.Lines.Add(EventInfo.GestureID.ToString + '=' + s); // case EventInfo.GestureID of sgiLeft, sgiRight: begin // ... delete it? or let the user click on "Delete button" LI := ListView1.Selected; // if (LI <> nil) and (LI <> LastLI) then begin ListView1.Items.Delete(LI.Index); // or other action... // LastLI := LI; end; end; end; Edited January 13, 2023 by programmerdelphi2k Share this post Link to post
sjordi 39 Posted January 13, 2023 Thank you. That seems to work. I have to combine this now with my OnItemClickEX event and see whether we can combine that. Also the problem is that the item is not moving. I'll see whether it's possible to make the Item itself slide right or left so the user can visually see what happens. Thanks a lot for your example, this is of huge help. Steve Share this post Link to post
programmerdelphi2k 237 Posted January 13, 2023 try use a "Effect" like "FloatAnimation" over Item Share this post Link to post
sjordi 39 Posted January 19, 2023 Ok I tried this but I can't attach the animation to an item. Maybe I'm missing something. I guess I have to do it programmatically by adding it to a TListViewItem. I'll post back here if I succeed. Share this post Link to post
sjordi 39 Posted September 10 I did not work extensively on this but I'm able to detect whether it's a right or left swipe, but the red button always appears on the right, not the left. That means I can't add option to the left when swiping right. If I try one of these coming days, I'll let you know Share this post Link to post