Re: How to get a CF_HDROP from javascript
gwtc <[email protected]> Mon, 03 Apr 2006 13:38:40 -0700
| Newsgroups | gmane.comp.mozilla.devel.windows |
|---|---|
| Message-ID | <[email protected]> |
Harry wrote: > I have a variable lf of type nsILocalFile and I want to get the CF_HDROP > clipboard format (from javascript, latest FF1.5). > > My understanding is that I need to put a "application/x-moz-file" > flavour in the clipboard, but setTransferData seems to fail. > Somehow there is a CF_HDROP on the clipboard, but seems to be zero data. > > I tried many variants of pointers (nsIFile, nsILocalFile, nsISupports), > also I used nsISupportsString encapsulating nsIFile.path, nsIURI.spec > but nothing helps. > > I'm able to put it there as text as "text/unicode" or > "application/x-moz-url", but thats not what I want to realize. > > Following snipped gives an idea whats not working ... > > const CI=Components.interfaces; > // lf = nsILocalFile > // uri= nsIURI > > var gClipboard = > Components.classes["@mozilla.org/widget/clipboard;1"].getService(CI.nsIClipboard); > var trans = > Components.classes["@mozilla.org/widget/transferable;1"].createInstance(CI.nsITransferable); > > var kFileMime="application/x-moz-file"; > > trans.addDataFlavor(kFileMime); > // trans.setTransferData(kFileMime, lf.QueryInterface(CI.nsISupports), 4); > > // trans.setTransferData(kFileMime, lf, 4); // 4=pointer size > // trans.setTransferData(kFileMime, lf, 1); > // trans.setTransferData(kFileMime, lf, lf.path.length); > // trans.setTransferData(kFileMime, lf, lf.path.length*2); > // trans.setTransferData(kFileMime, uri, 4); > // trans.setTransferData(kFileMime, uri, 1); > // trans.setTransferData(kFileMime, uri, uri.spec.length); > // trans.setTransferData(kFileMime, uri, uri.spec.length*2); > > var sstr = > Components.classes["@mozilla.org/supports-string;1"].createInstance(CI.nsISupportsString); > var text=uri.spec; > sstr.data=text; > // trans.setTransferData(kFileMime, sstr, text.length); > // trans.setTransferData(kFileMime, sstr, text.length*2); > > Any ideas? > Harry try posting in the mozilla javascript newsgroup. They might beable to help you better there: news://news.mozilla.org/mozilla.dev.tech.javascript -- Time for another change