Phil
On Tue, 29 Dec 2009 16:59:56 +0000, Axel Grude wrote:
> Hello,
>
> Hi I am trying to get a UID or URI from the smartfolder after a drag and
> drop operation, but the URI is not supported
>
> the flavour.contentType seems to be "text/x-moz-folder" but there is no
> URI? I looked at in the debugger and did not get _any_ data in this function
>
> onDrop: function (evt,dropData,dragSession) {
> QuickFolders.Util.logDebugOptional("dnd",
> "toolbarDragObserver.onDrop " + dropData.flavour.contentType);
> switch (dropData.flavour.contentType) {
> case "text/x-moz-folder":
> var sourceUri;
> var msgFolder = evt.dataTransfer.mozGetDataAt(
> "text/x-moz-folder", 0);
> sourceUri = msgFolder.URI;
>
> In Watches, msgFolder is shown as {const CPComponent} but there are no
> methods/properties to expand? The only thing that seems bring up
> something is the debug menu "Include ECMA Properties" but it doesn't
> seem to expose any interfaces. I have tried to look at
>
> http://mxr.mozilla.org/comm-1.9.1/ident?i=smartFolder
>
> but I did not find any definition for smartFolders; is there a base type
> for this that I can look up somewhere?
>
> thx
> Axel
--
-==-
Philip Chee <phi...@aleytys.pc.my>, <phili...@gmail.com>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
- David
Okay,
So how do I retrieve the folder URI from the drop event?
1st, is "text/x-moz-folder" the correct type for dragging the smart folder:
var msgFolder = evt.dataTransfer.mozGetDataAt("text/x-moz-folder", 0);
I tried msgFolder.getURI() but that doesn't return anything.
I can not find any interfaces in the debugger, is it possible to
typecast to nsMsgLocalMailFolder or convert to a nsMsgLocalMailFolder?
I am only used to C++ style type casts, so how would I do it in
Javascript? Bear with me as I don't really know when to use a var and
when an object(?) typeless programming is always a bit of a gamble to me.
Also while we're on the topic of dragging folders, (in TB3) there
appears also a drop event on dragged newsgroup folders, any chance to
get at their folder URI? Or is this a bug and dragging won't be
supported for NG folders in the final release?
sorry for asking so many Questions, Questions...
thanks in advance
Axel
I tried
var msgFolder = evt.dataTransfer.mozGetDataAt("text/x-moz-folder", 0);
sourceUri =
msgFolder.QueryInterface(Components.interfaces.nsIMsgFolder).URI;
- seems to do the trick - need to test with SM and Pb yet.
Last question regarding Smart Folders: when selecting a Smart Folder
there is no FOlderLoaded event - is there any other event that I could
catch? I need to highlight the select SmartFolder on my extension's toolbar.
> Also while we're on the topic of dragging folders, (in TB3) there
> appears also a drop event on dragged newsgroup folders, any chance to
> get at their folder URI? Or is this a bug and dragging won't be
> supported for NG folders in the final release?
Debugging a drop event for NG to my toolbar threw this error:
Error: transferData.first is null
Source file: chrome://global/content/nsDragAndDrop.js
Line: 459
its thrown when trying to call transferData.first.first:
var multiple =
"canHandleMultipleItems" in
aDragDropObserver && aDragDropObserver.canHandleMultipleItems;
-> var dropData = multiple ? transferData : transferData.first.first;
aDragDropObserver.onDrop(aEvent, dropData, this.mDragSession);
aEvent.stopPropagation();
thanks in advance
Axel
>> Also while we're on the topic of dragging folders, (in TB3) there
>> appears also a drop event on dragged newsgroup folders, any chance to
>> get at their folder URI? Or is this a bug and dragging won't be
>> supported for NG folders in the final release?
>
> Debugging a drop event for NG to my toolbar threw this error:
> Error: transferData.first is null
> Source file: chrome://global/content/nsDragAndDrop.js
> Line: 459
>
> its thrown when trying to call transferData.first.first:
>
> var multiple =
> "canHandleMultipleItems" in
> aDragDropObserver && aDragDropObserver.canHandleMultipleItems;
> -> var dropData = multiple ? transferData : transferData.first.first;
> aDragDropObserver.onDrop(aEvent, dropData, this.mDragSession);
> aEvent.stopPropagation();
The code here might give you some ideas:
<http://mxr.mozilla.org/comm-central/source/suite/mailnews/messengerdnd.js#246>
Phil
--