SWT:Drag and Drop in the Eclipse UI

SWT:Drag and Drop in the Eclipse UI

1, Drag Source
    samples:  private DropTarget dropTarget;
                    dropTarget = new DropTarget(dropControl, DND.DROP_COPY);//dropControl为drap操作的目标 对象
                   dropTarget.setTransfer(TextTransfer.getInstance());


2, Drop Target
3, Allowed Operation:DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK or DND.DROP_NONE.
4, Transfer Types:TextTransfer,RTFTransfer,FileTransfer,HtmlTransfer.
  sample: TextTransfer transfers=TextTransfer.getInstance(); 
5,dragOver event.feedback values

dragOver event.feedback values Description
DND.FEEDBACK_SELECT The item under the cursor is selected; applies to table and trees.
DND.FEEDBACK_SCROLL The widget is scrolled up or down to allow the user to drop on items that are not currently visible; applies to tables and trees.
DND.FEEDBACK_EXPAND The item currently under the cursor is expanded to allow the user to select a drop target from a sub item; applies to trees.
DND.FEEDBACK_INSERT_BEFORE An insertion mark is shown before the item under the cursor; applies to trees.
DND.FEEDBACK_INSERT_AFTER An insertion mark is shown after the item under the cursor; applies to trees.
DND.FEEDBACK_NONE No effect is shown.

samples: private int dropFeedback = 0;
         dropFeedback = DND.FEEDBACK_SCROLL;
         event.feedback = dropFeedback;
         如果你的对象超界了,当你的鼠标在边界上时就会自动住下滚动.

你可能感兴趣的:(SWT:Drag and Drop in the Eclipse UI)