Results 1 to 6 of 6

Thread: Window 'onDrag' event

  1. #1
    Sencha User
    Join Date
    Dec 2009
    Posts
    12

    Default Window 'onDrag' event

    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...

  2. #2
    Sencha User
    Join Date
    Nov 2009
    Posts
    61

    Default

    Hi unlex,

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

  3. #3
    Sencha User
    Join Date
    Dec 2009
    Posts
    12

    Post

    Quote Originally Posted by tomtom- View Post
    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:

    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...

  4. #4
    Sencha User
    Join Date
    Nov 2009
    Posts
    61

    Default

    There are many ways to do this:

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

    Code:
    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.

  5. #5
    Sencha User
    Join Date
    Dec 2009
    Posts
    12

    Default

    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.

  6. #6
    Sencha User
    Join Date
    Nov 2009
    Posts
    61

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •