1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    38
    Vote Rating
    0
    crashedsnow is on a distinguished road

      0  

    Default Cancel Drag on key event (Escape)

    Cancel Drag on key event (Escape)


    Hi all,

    I'm trying to find a way to abort a drag-drop "mid-drag" when the user clicks escape.

    So once the drag has commenced (and the item being dragged is displayed), I want to be able to cancel or abort this drag process when the user hits the escape key. So the subsequent drop event will not fire.

    Anyone got a way to solve this?

    Thanks.

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,445
    Vote Rating
    129
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    I wanted this behavior in an app we are writing and did the following...

    Code:
    Ext.getBody().on('keydown', function(e, t) {
        if (e.ESC === e.getKey()) {
            e.stopEvent();
            var drag = Ext.dd.DDM.dragCurrent;
            drag.onInvalidDrop(t, e);
            Ext.dd.DDM.dragCurrent = null;
        }
    });
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Location
    Netherlands
    Posts
    25
    Vote Rating
    1
    jvisser is on a distinguished road

      0  

    Default


    This used to work in Ext 4.0.7 but now in 4.1.2 it doesn't seem to be working anymore. Setting Ext.dd.DDM.dragCurrent to null kills everything. And not setting Ext.dd.DDM.dragCurrent to null doesn't stop the drop.

    Did this happen to you, and how did you fix it?

Thread Participants: 2