Klaus Nowikow wrote: > Hi, > > I am trying to drag some data in form of a nsIRDFResource > from one window of my xulrunner application to another one. > > Creating an interface pointer object > (@mozilla.org/supports-interface-pointer;1) > and adding this to the SupportsArray fails when I try to get the transfer > data at the drop site.
I thought I'd post some code to show what I did. I am using PyXPCOM, the platform is xulrunner-i686-pc-linux-gnu (xulrunner 1.9a6pre). When I use a string ('@mozilla.org/supports-string;1') object for the drag data instead of the rdf resource, everything works fine. In the ondraggesture handler of the drag source (a XUL tree): <code> dragService = components.classes['@mozilla.org/widget/dragservice;1'].getService(nsIDragService) rdf = components.classes['@mozilla.org/rdf/rdf-service;1'].getService(nsIRDFService) resource = components.classes[ '@mozilla.org/supports-interface-pointer;1' ].createInstance(nsISupportsInterfacePointer) resource.dataIID = nsIRDFResource resource.data = rdf.GetAnonymousResource() transferable = components.classes[ '@mozilla.org/widget/transferable;1' ].createInstance(nsITransferable) transferable.addDataFlavor('application/x-my-test') transferable.setTransferData('application/x-my-test', resource, 1) transferables = components.classes[ '@mozilla.org/supports-array;1' ].createInstance(nsISupportsArray) transferables.AppendElement(transferable) # event is the nsIDOMMouseEvent dragService.invokeDragSession( event.target, transferables, None, nsIDragService.DRAGDROP_ACTION_COPY ) event.stopPropagation() </code> And in the ondragdrop handler of the drop target: <code> dragService = components.classes[ '@mozilla.org/widget/dragservice;1' ].getService(nsIDragService) session = dragService.getCurrentSession() if not session.isDataFlavorSupported('application/x-my-test'): return for index in range(0, session.numDropItems): transferable = components.classes[ '@mozilla.org/widget/transferable;1' ].createInstance(nsITransferable) transferable.addDataFlavor('application/x-my-test') session.getData(transferable, index) # This line fails!!! It works when I use a supports-string object # instead of the rdf resource data, len = transferable.getTransferData('application/x-my-test') print data, len event.stopPropagation() </code> _______________________________________________ dev-tech-xpcom mailing list dev-tech-xpcom@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-xpcom