Skip to main content
heyo
Associate III
December 13, 2023
Question

Drag elements between lists

  • December 13, 2023
  • 1 reply
  • 1283 views

save.png

Hello, I created two list, in picture I marked red and I want to drag list element to another and put element from list1 to list2. Is it possible? if not, maybe someone knows another idea?

This topic has been closed for replies.

1 reply

GaetanGodart
ST Employee
December 18, 2023

Hello @heyo ,

It seems feasible to me!
You can make your listLayouts clicklistener.
Here is the documentation for it :
 - clickListener developement guide 
 - clickListener API 

This will allow you to track clicks (and their location) and release (and their location).

The clickListener callback will only be called if a click happens inside the widget set as clickListener. From there you can wait for a "release" event and check it's location. Finally, compare that location with the coordinates and size (width and height) of your second listLayout to see of the release was made inside the second listLayout.
If that is the case, you can then call the method remove and the method insert to swap the widget that has to be moved.

The hard part will be to know which widget (the one you want to move) was clicked on (especially if your listLayout is scrollable).
Another consideration will be the position of the inserted widget.

Hope this helps.
Don’t hesitate to give us a feedback or give more precisions and tell us if the issue is solved! :smiling_face_with_smiling_eyes:

Gaetan GodartSoftware engineer at ST (TouchGFX)