B4J Question Drag & Drop many panes

LucaMs

Expert
Licensed User
Longtime User
This question is meant to drive @stevel05 crazy 😄


With a lot of "hard work", I managed to modify his jDragAndDrop2 project so that a Pane is dragged onto another and the latter becomes its parent.

java_H5fCYrSEAP.gif


Having N Panes and wanting to move one of them, how do I detect on which of them I release the moved Pane?


Goal (not easy): use the native TreeView giving the user the ability to move nodes, modify the TreeView structure.
 
Last edited:

MicroDrie

Well-Known Member
Licensed User
Longtime User
I don't know how exactly you created the layout, nor how you detect drops, but for those initial panels you may be able to determine the order of which panel is being dragged based on a panel tag.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
In the _DragDropped sub you can use e.GetEventTarget method to get the view that was dropped on.
I stopped at the first property that seemed the most suitable:
e.GetAcceptingObject
which returns a very strange thing.

e.GetEventTarget is very useful but the problem remains that you have to set MakeDragSource and MakeDragTarget for a single DragAndDrop object.

I'm afraid I should create a DragAndDrop object for every existing node pair. :(
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I'm afraid I should create a DragAndDrop object for every existing node pair
Yes a daunting task indeed. The most straightforward way to achieve this, although by no means simple, would be to create a Cell Factory for the Treeview and handle that in there.

You would need to delve into Java to achieve this method.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
would be to create a Cell Factory for the Treeview and handle that in there.

You would need to delve into Java to achieve this method.
Thanks, but I should study for about 88 days (just because I like the number 88) 😄

I could try using my library:
https://www.b4x.com/android/forum/threads/b4x-b4xlib-lmb4xpermutations.165073/#content

but I still don't know if it would work, detecting everything, which DragAndDrop object is "running", which nodes and who knows what else.

By the way, I should do the first test on a TreeView, directly setting the source and target node.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I could not get the base node of a TreeItem (I assume it exists).

So I'll have to create a TreeView from scratch.
I had forgotten that I have to create a TreeView anyway from scratch, because I want it to have another type of view in addition to the nodes (branches-leaves), which allows me to place "AND" or "OR" between branches and/or leaves.
 
Upvote 0
Top