I've written an application recently using SWT. In one of its dialog box, I have a few widgets, one of which is Text, which is designed to support DND with other widgets. I've first added DND support for the 2 Tree widgets on the same dialog box (both drag source and drop target). Before I added DND support for that Text widget, I noticed that on Linux platform (gtk), SWT Text widget automatically get drag and drop support. That is, I can already drag from the other Tree widgets and drop on this Text (at any position to inserted there), as well as selecting and dragging any text from this Text to other Tree or Text widget.
However, this is only working on Linux platform but not on Windows. The same program, if running on Windows, will not have any DND support for that Text widget (Tree widgets of course have DND support since I specifically write for them).
So here's what I want to achieve on Windows as well:
drop text at any position in Text widget.
before dropping and while hovering, able to see the caret position clearly where the intended position to drop. caret position should move along with the mouse cursor.
support multi-line in Text widget
SOLUTION:
DropTarget target = new DropTarget(sytledText, DND.DROP_MOVE | DND.DROP_COPY);
target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
target.addDropListener(new StyleTextDropTargetEffect(sytledText));
Use StyledText instead of Text widget
Use StyledTextDropTargetEffect (or extend it) and add it as dr op listener