I am trying to implement a DragAndDrop capability on a ScrolledForm with several expandable Sections. I should be able to move sections around in the form, reordering them.
After a bit (a lot) of research, I’ve learned that my best chance is to define my own custom Transfer for the DragSource and DropTarget.
All in all, how can you move around a Control in a Composite?
Update:
Alright, so. My Sections no longer need to be expandable. They are ‘solid’ sections of different sizes. This eases my problem but doesn’t solve it.
I’ve tried variations of Drag and Drop, with and without aTransfer. The all-mighty Internet didn’t think about implementing something like this.
As you mentioned, you have to implement
DragSourceandDropTarget. When you drag acontrol, you could actually changecursorto image of the actual control ( Look atControl.print(GC)method to createImage). All you need to do once the drop is finished is change bounds of theControl.(Control.setBounds (int x, int y, int width, int height) )As you want to lay out your
Controlsin free form, I would suggest you to restrict to set anyLayouton the form and you have to manually calculate and set bounds on each childControl.