[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: How to use dropAccept()

Mark Levison wrote:
I've tried to write dropAccept() (implementing DropTargetListener) and I can't get it to work.

Naively I assumed that in dropAccept() the event.data field would be populated. So I wrote:

dropAccept(DropTargetEvent event) {
    if (false == (event.data instanceof FooBar)) {
       event.detail = DND.DROP_NONE;
    }
}

The problem is that event.data is null - so I would never accept any drops.

I had a look at the event.currentDataType in the debugger and I'm just confused.

So how do implement dropAccept so that can reject any drops that aren't going to be of type foobar.
Hi Mark. I'm not familiar with the dropAccept() method. I found the article below to be very helpful.
http://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html


Also, have you looked at the SWT Snippets for Drag and Drop?
http://www.eclipse.org/swt/snippets/

Hope this helps. Mark