Re: Drag and drop items between list views
Posted by
MartinW on
Apr 02, 2014; 3:08pm
URL: https://forum.world.st/Drag-and-drop-items-between-list-views-tp4752285p4752328.html
I tried the following, but i do not know what to do in the acceptDropBlock. It seems the receiver in the block is only an item in a list, but how do i get the receiving list/collection?
What i want to achieve is that a user can drag the '1' from list1 to list2 and the resulting collections will then be collection1: (2 3 4 5) collection2: ($a $b $c $d $e 1) and the lists will be updated accordingly.
| collection1 collection2 list1 list2 |
collection1 := #(1 2 3 4 5).
collection2 := #($a $b $c $d $e).
list1 := ListModel new.
list1 items: collection1.
list1 dragEnabled: true.
list1 dropEnabled: true.
list1 acceptDropBlock: [ :transfer :event :source :receiver :index | self halt ].
list1 openWithSpec.
list2 := ListModel new.
list2 items: collection2.
list2 dragEnabled: true.
list2 dropEnabled: true.
list2 acceptDropBlock: [ :transfer :event :source :receiver :index | self halt ].
list2 openWithSpec.
Goubier Thierry wrote
yes, most list-like widgets can drag and drop. Feedback when inserting
items in lists could be improved, however (i.e. you can drop on a list
item, but I've never seen the feedback for dropping between list items).
Le 02/04/2014 16:09, MartinW a écrit :
> i have to make a UI where users can sort items (sentences) into different
> collections by dragging and dropping them between list views. Is this
> possible with the widgets currently available in Pharo?