Bug 145587 - [DND] Eclipse's Drag-n-drop does not give user-defined data for the dragOver() method?
Summary: [DND] Eclipse's Drag-n-drop does not give user-defined data for the dragOver(...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Duong Nguyen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 145453 145586 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-06 13:42 EDT by Alex Le CLA
Modified: 2006-11-20 13:55 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Le CLA 2006-06-06 13:42:06 EDT
Hi,

I am trying out Snippet210.java and I can only get the actual data in the drop() method but not dragOver() method?  How can one passs user defined data or data simply when dragOver() is called?  Does Eclipse's SWT support this at all?

That is:  When I add the below method into the snippet.  The data is always echo out as null.

public void dragOver(DropTargetEvent e)
        {
            System.out.println("dragOver: " + (String)e.data);
        }
Comment 1 Grant Gayed CLA 2006-06-06 15:01:20 EDT
*** Bug 145586 has been marked as a duplicate of this bug. ***
Comment 2 Grant Gayed CLA 2006-06-06 16:24:32 EDT
*** Bug 145453 has been marked as a duplicate of this bug. ***
Comment 3 Veronika Irvine CLA 2006-06-06 20:47:49 EDT
You can get the data in the drag over on Windows only as follows:

public void dragOver(DropTargetEvent event) {
	event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
	if (textTransfer.isSupportedType(event.currentDataType)) {
	    // NOTE: on unsupported platforms this will return null
	    Object o = textTransfer.nativeToJava(event.currentDataType);
	    String t = (String)o;
	    if (t != null) System.out.println(t);
	}
}

For more info, read the following article:

http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html
Comment 4 Alex Le CLA 2006-06-07 17:32:56 EDT
(In reply to comment #3)
> You can get the data in the drag over on Windows only as follows:
> public void dragOver(DropTargetEvent event) {
>         event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
>         if (textTransfer.isSupportedType(event.currentDataType)) {
>             // NOTE: on unsupported platforms this will return null
>             Object o = textTransfer.nativeToJava(event.currentDataType);
>             String t = (String)o;
>             if (t != null) System.out.println(t);
>         }
> }
> For more info, read the following article:
> http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html

Thank you...How would you apply the above to Snippet79?
Comment 5 Alex Le CLA 2006-06-07 17:34:19 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > You can get the data in the drag over on Windows only as follows:
> > public void dragOver(DropTargetEvent event) {
> >         event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
> >         if (textTransfer.isSupportedType(event.currentDataType)) {
> >             // NOTE: on unsupported platforms this will return null
> >             Object o = textTransfer.nativeToJava(event.currentDataType);
> >             String t = (String)o;
> >             if (t != null) System.out.println(t);
> >         }
> > }
> > For more info, read the following article:
> > http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html

> Thank you...How would you apply the above to Snippet79?

Please ignore the above question! Thanks!

Comment 6 Duong Nguyen CLA 2006-11-20 13:55:52 EST
I tried the sample code in the DnD article http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html and it appears to work.