Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » [Drag and Drop] why are DragSourceEvent.{data, dataType} both null in dragFinished()?
[Drag and Drop] why are DragSourceEvent.{data, dataType} both null in dragFinished()? [message #465477] Wed, 14 December 2005 18:58 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
I have a Tree, with a DragSourceListener and a DropTargetListener, and I can drag and drop
(DROP_COPY) items within the tree, and everything works. Great!

Now I want to be able to have the user press some key (CTRL or SHIFT, maybe) and allow DROP_MOVE.
I've looked through this newsgroup, and repeatedly read both the articles:

http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.h tml
http://www.eclipse.org/articles/Article-Workbench-DND/drag_d rop.html

So, from those articles I learn that, in the DragSourceListener#dragFinished() method, "If a move
operation has been performed, remove the data from the source" -- see
http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.h tml#_ds29C ...

BUT when that method is called, both the event.data and the event.dataType are ALWAYS null. So how
am I supposed to tell what was dragged so as to be able to remove it? The example does not at all
answer the question, since it hardwires ONE drag source for all time -- not a very useable example,
for this question, since nearly all possible applications of a DragSourceListener will involve
multiple possible items as actual sources (e.g., in a Tree).

thanks,
Paul
Re: [Drag and Drop] why are DragSourceEvent.{data, dataType} both null in dragFinished()? [message #465544 is a reply to message #465477] Thu, 15 December 2005 01:11 Go to previous messageGo to next message
Christopher Goy is currently offline Christopher GoyFriend
Messages: 38
Registered: July 2009
Member
Did you look at the setData(DragSourceEvent event) method? You can set your
drag data there.


Hope this helps

Chris
"Paul Keyser" <rolarenfan@earthlink.net> wrote in message
news:dnpq0v$ok2$1@news.eclipse.org...
>I have a Tree, with a DragSourceListener and a DropTargetListener, and I
>can drag and drop (DROP_COPY) items within the tree, and everything works.
>Great!
>
> Now I want to be able to have the user press some key (CTRL or SHIFT,
> maybe) and allow DROP_MOVE. I've looked through this newsgroup, and
> repeatedly read both the articles:
>
> http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.h tml
> http://www.eclipse.org/articles/Article-Workbench-DND/drag_d rop.html
>
> So, from those articles I learn that, in the
> DragSourceListener#dragFinished() method, "If a move operation has been
> performed, remove the data from the source" -- see
> http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.h tml#_ds29C ...
>
> BUT when that method is called, both the event.data and the event.dataType
> are ALWAYS null. So how am I supposed to tell what was dragged so as to be
> able to remove it? The example does not at all answer the question, since
> it hardwires ONE drag source for all time -- not a very useable example,
> for this question, since nearly all possible applications of a
> DragSourceListener will involve multiple possible items as actual sources
> (e.g., in a Tree).
>
> thanks,
> Paul
Re: [Drag and Drop] why are DragSourceEvent.{data, dataType} both null in dragFinished()? [message #465548 is a reply to message #465544] Thu, 15 December 2005 02:38 Go to previous message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Well, I do set the event.data there -- that's required to make the DRAG_COPY work -- and the
event.dataType has been set for me to a valid type.

But apparently, somewhere deep inside SWT, the event.data and event.dataType are RESET to null after
a drop. This means that dragFinished() cannot really be used to implement DRAG_MOVE, as the SWT docs
suggest.

Paul
Previous Topic:org.eclipse.search
Next Topic:Components
Goto Forum:
  


Current Time: Tue Sep 24 10:50:32 GMT 2024

Powered by FUDForum. Page generated in 0.05891 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top