|
Re: browser + drag and drop [message #463073 is a reply to message #463023] |
Mon, 05 February 2007 23:41 |
Jacek Pospychala Messages: 159 Registered: July 2009 |
Senior Member |
|
|
Daniel,
it's possible. Look at swt snippet83, available at www.eclipse.org/swt
With a bit modified code you can see that, dragging a text provides you
with a String, while dragging an image provides with a path to image
file cached by the browser on disk.
To see this, let's change Snippet83.getNameFromId(int) to
getNameFromId(int,TransferData), and then modify the method so its part
will look like this:
case COM.CF_HDROP: // image
name = "CF_HDROP";
if (transferData != null) {
FileTransfer ft = FileTransfer.getInstance();
String[] r= (String[]) ft.nativeToJava(transferData);
name += " " + r[0]; // Append a path to file with image
}
break;
case COM.CF_TEXT: // text
name = "CF_TEXT";
if (transferData != null) {
name += " " +TextTransfer.getInstance().nativeToJava(transferData);
// append copied text
}
break;
Remember, to pass transferData in dragEnter(...) and null in constructor.
Jacek Pospychala
Daniel Beck napisał(a):
> Hello RCP mailing list,
>
>
> I want to implement drag and drop functionality between the
> org.eclipse.swt.browser and a custom made editor. Particularly, the
> software should support dragging pictures or text from the browser to
> the editor.
>
> I was not successful in implementing that drag and drop functionality. I
> wanted to ask if someone already did it, and how. (a code snippet would
> be great)
>
> Thanks and regards,
> Daniel
|
|
|
Re: browser + drag and drop [message #463295 is a reply to message #463073] |
Thu, 08 February 2007 02:56 |
Daniel Beck Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Jacek,
your solution worked, thanks!
Daniel
> Daniel,
> it's possible. Look at swt snippet83, available at www.eclipse.org/swt
>
> With a bit modified code you can see that, dragging a text provides you
> with a String, while dragging an image provides with a path to image
> file cached by the browser on disk.
>
> To see this, let's change Snippet83.getNameFromId(int) to
> getNameFromId(int,TransferData), and then modify the method so its part
> will look like this:
>
> case COM.CF_HDROP: // image
> name = "CF_HDROP";
> if (transferData != null) {
> FileTransfer ft = FileTransfer.getInstance();
> String[] r= (String[]) ft.nativeToJava(transferData);
> name += " " + r[0]; // Append a path to file with image
> }
> break;
> case COM.CF_TEXT: // text
> name = "CF_TEXT";
> if (transferData != null) {
> name += " " +TextTransfer.getInstance().nativeToJava(transferData);
> // append copied text
> }
> break;
>
> Remember, to pass transferData in dragEnter(...) and null in constructor.
>
> Jacek Pospychala
>
> Daniel Beck napisał(a):
>> Hello RCP mailing list,
>>
>>
>> I want to implement drag and drop functionality between the
>> org.eclipse.swt.browser and a custom made editor. Particularly, the
>> software should support dragging pictures or text from the browser to
>> the editor.
>>
>> I was not successful in implementing that drag and drop functionality.
>> I wanted to ask if someone already did it, and how. (a code snippet
>> would be great)
>>
>> Thanks and regards,
>> Daniel
|
|
|
Powered by
FUDForum. Page generated in 0.03839 seconds