Prevent "swiping out" of TListBox item

291 Views Asked by At

I have a Delphi Berlin build Android app which contains a TListBox. At some point I manually add a TListItem (code below). Unfortunatelly the user can do a right or left swipe on it which seems to remove the list item and that does something which crashes the app at some later point.

How to disable the ability to swipe right or left on the TListBoxItem? I didn't see any Swipe to delete kind of functionality and I already tried to capture the swipe right gesture without luck. If I set Selectable to false I can't swipe it anymore, but then the painting of the Item above gets removed.

Code to add the item at runtime:

procedure TMyForm.InfoButtonCLick(Sender: TObject)
var
 Item : TListBoxItem;
begin
  Item                  := TListBoxItem.Create(nil);
  Item.Text             := '';
  Item.Height           := 200; 
  Item.HitTest          := false;
  Item.Selectable       := false;

  // Other things I tried without success
  //    Item.Touch.InteractiveGestures := [];
  //    Item.DragMode         := TDragMode.dmManual;
  // tried to capture swite right and left and declare them as handled
  //    Item.OnGesture        := OnListItemGesture;    

  // lb_Files is the ListBox
  lb_Files.InsertObject(lb_Files.ItemIndex + 1, Item);
  lb_Files.ScrollToItem(Item);
end;
0

There are 0 best solutions below