Results 1 to 3 of 3

Thread: Cancel Drag on key event (Escape)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    38
    Vote Rating
    0
      0  

    Default 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 User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,487
    Vote Rating
    146
      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

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Location
    Netherlands
    Posts
    30
    Vote Rating
    1
      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?

Posting Permissions

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