PDA

View Full Version : Window 'onDrag' event



unlex
12 Dec 2009, 2:00 AM
Hi!
Is there any method to simulate Window onDrag event? There is onMove but it's fired after window is moved. But I need to get window coordinates WHILE it is dragged. I tried to use Ext.dd.DragDrop but still can't figure out how to do it correctly.
Will appreciate any help...

tomtom-
13 Dec 2009, 2:02 PM
Hi unlex,

You have an onDrag event in the Ext.dd.DD class.
Use it overriding the onDrag event to retrieve the window coordinates !

unlex
13 Dec 2009, 11:48 PM
Hi unlex,

You have an onDrag event in the Ext.dd.DD class.
Use it overriding the onDrag event to retrieve the window coordinates !

I tried the following code:


var dd = new Ext.dd.DD('windowId');
dd.onDrag = function(e) {
console.log(Ext.getCmp('windowId').getPosition());
}

It's OK now, thanks! I can get window's coordinates but there is another problem - window is dragged while div with shadow not, i.e. shadow stays on initial coordinates...

tomtom-
14 Dec 2009, 2:01 AM
There are many ways to do this:

If your are using a window, a simple one is :



win = new Ext.Window({
id: 'windowId'
});
win.show();

win.dd.onDrag = function(e){
this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
console.log(this.lastPageX, this.lastPageY);
}


But it doesn't work with all containers.

unlex
14 Dec 2009, 5:07 AM
Thanks! It works great now.
But as far as I understand it's difficult to make some things in ExtJS without looking into sources. For example I couldn't find lastPageX and lastPageY properties in documentation until looked through DragDropMgr sources.

tomtom-
14 Dec 2009, 5:51 AM
In fact these properties are privates.
Moreover, this is an "easy" way to do this, but this isn't the good way following the framework.
To me, the good way to custom a dd events is extending the desired superclass overriding methods.
If you want you can try this and ask if you have any problem.

If my words are wrong, everyone can correct me.