PDA

View Full Version : how to implement Ext.air.DragType



digitalkaoz
4 Nov 2008, 12:35 AM
he guys,

i would like to implement a drag n drop functionality to my app, so imagine i would like to drag a picture from my pictures folder onto my air app, and when i drop it, something should happen.

can anyone gimme a hint?

I think Ext.air.DragType isnt the wrongest approach?

thanks

digitalkaoz
4 Nov 2008, 1:34 AM
ok got it after crawling through the tasks example, its not very clear, but it works

aconran
26 Nov 2008, 12:32 PM
digitalkaoz -

I'm interested in hearing what kind of API you would like to have in order to work with this functionality with ease. Please tell us how you would want it to work.

Thanks,

digitalkaoz
4 Dec 2008, 2:36 AM
he currently its working this way (text,files)


Ext.getBody().on("dragover",function(e){
if(e.hasFormat(Ext.air.DragType.TEXT) || e.hasFormat(Ext.air.DragType.FILES)){
e.preventDefault();
}
});
Ext.getBody().on("drop",function(e){
if(e.hasFormat(Ext.air.DragType.TEXT)){
var text = e.getData(Ext.air.DragType.TEXT);
alert(text);
}
if(e.hasFormat(Ext.air.DragType.FILES)){
var f = e.getData(Ext.air.DragType.FILES);
alert(f[0].url);
}
});


i could imagine that the air class could extend the default ext components so you can apply the "drop" or "dragover" events directly to an object configuration via the listeners config...

i could imagine something linke this....



{
xtype:'panel',
tile:'a default component',
listeners :{
"drag" : function(e,Ext.air.DragType.TEXT){},
"drop" : function(e,Ext.air.DragType.FILES){}
}
}


this event listeners should applyed to the components body element after rendering
i should work on all? components, and all air.events which are catchable by ext.

greetz digitalkaoz