Hi,

I'm using DragManager to drag some objects on the interface. And I'd like the 
dragging to be cancelled when the ESCAPE key is pressed. But I can't find a way 
to do it since DragManager doesn't seem to have a method for that.

Here's what my code looks like:

    private function keyHandler(event:KeyboardEvent):void {
        if (DragManager.isDragging && event.keyCode == Keyboard.ESCAPE){
            // TODO: Cancel drag here...
            stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
        }
    }

    public function startDrag(event:MouseEvent):void {
        ...
        DragManager.doDrag(dragInitiator, dragSource, event, image);
        stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
    }

Do you know how I could achieve this?

Thanks a lot,

Julien

Reply via email to