<p>Once I've called <code>DragManager.acceptDrag</code> is there any way to "unaccept" the drag? Say that I have a view which can accept drag and drop, but only in certain areas. Once the user drags over one of these areas I call <code>DragManager.acceptDrag(this)</code> (from a <code>DragEvent.DRAG_OVER</code> handler), but if the user then moves out of this area I'd like to change the status of the drag to not accepted and show the <code>DragManager.NONE</code> feedback. However, neither calling <code>DragManager.acceptDrag(null)</code> nor <code>DragManager.showFeedback(DragManager.NONE)</code> seems to have any effect. Once I've accepted the drag an set the feedback type I can't seem to change it.</p>

<p>Just to make it clear: the areas where the user should be able to drop are not components or even display objects, in fact they are just ranges in the text of a text field (like the selection). Had they been components of their own I could have solved it by making each of them accept drag events individually. I guess I could create proxy components that float over the text to emulate it, but I'd rather not if it isn't necessary.</p>

<hr>

<p>I've managed to get it working in both AIR and the browser now, but only by putting proxy components on top of the ranges of text where you should be able to drop things. That way I get the right feedback and drops are automatically unaccepted on drag exit.</p>

<p>This is the oddest thing about D&amp;D in AIR:</p>

<pre><code>DragManager.doDrag(initiator, source, event, dragImage, offsetX, offsetY);
</code></pre>

<p>In browser-based Flex, <code>offsetX</code> and <code>offsetY</code> should be negative (so says the documentation, and it works fine). However, when running <em>exactly the same code</em> in AIR you have to make the offsets positive. The same numbers, but positive. That is very, very weird.</p>

<hr>

<p>I've tested some more and what <a href="https://stackoverflow.com/questions/10870/how-can-i-unaccept-a-drag-in-flex#11209">@maclema</a> works, but not if you run in AIR. It seems like drag and drop in AIR is different. It's really, really weird because not only is the feedback not showing correctly, and it's not possible to unaccept, but the coordinates are also completely off. I just tried my application in a browser instead of AIR and dragging and dropping is completely broken.</p>

<p>Also, skipping the <code>dragEnter</code> handler works fine in AIR, but breaks everything when running in a browser.</p>

[{'answer_id': 11209, 'author': 'Matt MacLean', 'author_id': 22, 'author_profile': 'https://Stackoverflow.com/users/22', 'pm_score': 3, 'selected': False, 'text': '<p>Are you using only the dragEnter method? If you are trying to reject the drag while still dragging over the same component you need to use both the dragEnter and dragOver methods.</p>\n\n<p>Check out this example:</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;\n&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;\n    &lt;mx:Script&gt;\n        &lt;![CDATA[\n            import mx.core.DragSource;\n            import mx.managers.DragManager;\n            import mx.events.DragEvent;\n\n            private function onDragEnter(e:DragEvent):void {\n                if ( e.target == lbl ) {\n\n                    if ( e.localX &lt; lbl.width/2 ) {\n                        trace("accept");\n                        DragManager.acceptDragDrop(this);\n                    }\n                    else {\n                        DragManager.acceptDragDrop(null);\n                    }\n                }\n            }\n\n            private function doStartDrag(e:MouseEvent):void {\n                if ( e.buttonDown ) {\n                    var ds:DragSource = new DragSource();\n                    ds.addData("test", "text");\n\n                    DragManager.doDrag(btn, ds, e);\n                }\n            }\n        ]]&gt;\n    &lt;/mx:Script&gt;\n    &lt;mx:Label id="lbl" text="hello world!" left="10" top="10" dragEnter="onDragEnter(event)" dragOver="onDragEnter(event)" /&gt;\n    &lt;mx:Button id="btn" x="47" y="255" label="Button" mouseMove="doStartDrag(event)"/&gt;\n&lt;/mx:Application&gt;\n</code></pre>\n'}, {'answer_id': 12552, 'author': 'Matt MacLean', 'author_id': 22, 'author_profile': 'https://Stackoverflow.com/users/22', 'pm_score': 0, 'selected': False, 'text': '<p>ok, I see the problem now. Rather than null, try setting it to the dragInitiator.</p>\n\n<p>Check this out.</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;\n&lt;mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;\n    &lt;mx:Script&gt;\n        &lt;![CDATA[\n            import mx.controls.Alert;\n            import mx.events.DragEvent;\n            import mx.managers.DragManager;\n            import mx.core.DragSource;\n\n            private function doStartDrag(e:MouseEvent):void {\n                if ( e.buttonDown &amp;&amp; !DragManager.isDragging ) {\n                var ds:DragSource = new DragSource();\n                ds.addData("test", "test");\n\n                DragManager.doDrag(btn, ds, e);\n                }\n            }\n\n            private function handleDragOver(e:DragEvent):void {\n                if ( e.localX &lt; cvs.width/2 ) {\n                    //since null does nothing, lets just set to accept the drag\n                    //operation, but accept it to the dragInitiator\n                    DragManager.acceptDragDrop(e.dragInitiator);\n                }   \n                else {\n                    //accept drag\n                    DragManager.acceptDragDrop(cvs);\n                    DragManager.showFeedback( DragManager.COPY );\n                }\n            }\n\n            private function handleDragDrop(e:DragEvent):void {\n                if ( e.dragSource.hasFormat("test") ) {\n                    Alert.show("Got a drag drop!");\n                }\n            }\n        ]]&gt;\n    &lt;/mx:Script&gt;\n    &lt;mx:Canvas x="265" y="66" width="321" height="245" backgroundColor="#FF0000" id="cvs" dragOver="handleDragOver(event)" dragDrop="handleDragDrop(event)"&gt;\n    &lt;/mx:Canvas&gt;\n    &lt;mx:Button id="btn" x="82" y="140" label="Drag Me" mouseDown="doStartDrag(event)"/&gt;\n&lt;/mx:WindowedApplication&gt;\n</code></pre>\n'}, {'answer_id': 16376, 'author': 'Matt MacLean', 'author_id': 22, 'author_profile': 'https://Stackoverflow.com/users/22', 'pm_score': 0, 'selected': False, 'text': '<p>Yes, drag and drop is different in AIR. I HATE that! It takes a lot of playing around to figure out how to get things to work the same as custom dnd that was built in flex.</p>\n\n<p>As for the coordinates, maybe play around with localToContent, and localToGlobal methods. They may help in translating the coordinates to something useful.</p>\n\n<p>Good luck. I will let you know if I think of anything else.</p>\n'}, {'answer_id': 90321, 'author': 'Christophe Herreman', 'author_id': 17255, 'author_profile': 'https://Stackoverflow.com/users/17255', 'pm_score': 1, 'selected': False, 'text': '<p>If you don\'t need native drag and drop in AIR, you can get the Flex drag and drop behavior by subclassing WindowedApplication and setting the DragManager. See this post on the Adobe Jira for more info: <a href="https://bugs.adobe.com/jira/browse/SDK-13983" rel="nofollow noreferrer">https://bugs.adobe.com/jira/browse/SDK-13983</a></p>\n'}, {'answer_id': 15009919, 'author': 'bebbo', 'author_id': 1412279, 'author_profile': 'https://Stackoverflow.com/users/1412279', 'pm_score': 1, 'selected': False, 'text': '<p>You are misunderstanding the concept. Your "unaccept" is achieved by implementing the dragOverHandler and signaling that the data is not wanted.</p>\n\n<p>Here is the basic concept:</p>\n\n<ol>\n<li><p>register the dragEnterHandler or override the already registered method.</p>\n\n<pre><code>function dragEnterHandler(event: DragEvent):void {\n    if (data suites at least one location in this component)\n        DragManager.acceptDragDrop(this);\n}\n</code></pre>\n\n<p>This enables your container to receive further messages (dragOver/dragExit). But this is <strong>NOT</strong> the location to decide which kind of mouse cursor should be displayed.</p>\n\n<p>Without <strong>DragManager.acceptDragDrop(this);</strong> the other handlers aren\'t called.</p></li>\n<li><p>register the dragOverHandler or override the already registered method.</p>\n\n<pre><code>function dragOverHandler(event: DragEvent):void {\n    if (data suites at least no location in this component) {\n        DragManager.showFeedback(DragManager.NONE);\n        return;\n    }\n\n    ... // handle other cases and show the cursor / icon you want\n}\n</code></pre>\n\n<p>Calling <strong>DragManager.showFeedback(DragManager.NONE);</strong> does the trick to display the "unaccept".</p></li>\n<li><p>register the dragExitHandler or override the already registered method.</p>\n\n<pre><code>function dragOverHandler(event: DragEvent):void {\n    // handle the recieved data as you like.\n}\n</code></pre></li>\n</ol>\n'}]
['https://Stackoverflow.com/questions/10870', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1109/']