PDA

View Full Version : A question about custom D&G



pegaso52it
16 Jul 2009, 11:20 PM
Hi all,
My application has an "help" button in the toolbar, and several fields (text, combo, radio and so on) in the form panel.

I'd like to drag the "help" toolbar button and drop it on one of the form field to open a contextual help (just like others applications do)

I have read the tutorial ( http://extjs.com/learn/Tutorial:Custom_Drag_and_Drop_Part_1 )
and the way that it illustrates is to define a proxy for each "drop target" component, so a proxy for each form field.

But tutorial says also that is one of the ways to solve to problem, but not the only way.

So, is there a way to solve my problem without having a proxy for each form field?

After drop I need only to know the "drop target" component id to open my contextual help....

Thank you very much for your time.

Lukman
17 Jul 2009, 12:02 AM
In afterrender event of your panel, instantiate an Ext.dd.DragSource object by passing panel.getTool('help') in its constructor. Make sure to set ddGroup. Then configure your form fields as Ext.dd.DropTarget() with the same ddGroup. Handle a drop event accordingly.

DragSource:


... new Ext.Panel({
...
listeners: {
afterrender: function(panel) {
panel.help_ds = new Ext.dd.DragSource(panel.getTool('help'), {
ddGroup: 'dd_help'
});
}
...
},
...
});DropTarget:



... new Ext.form.TextField({
...
listeners: {
afterrender: function(comp) {
comp.help_dt = new Ext.dd.DropTarget(comp.el, {
ddGroup: 'dd_help',
notifyDrop: function(source, e, obj) {
alert('Help me!');
return true;
}
});
}
...
},
...
});