Community
Participate
Working Groups
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); }
*** Bug 145586 has been marked as a duplicate of this bug. ***
*** Bug 145453 has been marked as a duplicate of this bug. ***
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
(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?
(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!
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.