我想从 AIR 应用程序内部和外部将内容放入 HTMl 组件中。从应用程序外部删除工作正常,但我不能从列表中删除 stuf,调用 acceptDragDrop 没有视觉效果,也没有功能效果,不会调度 drop 事件。我尝试只使用 DragManager,然后只使用 NativeDragManager 但效果相同。我不明白缺少什么,为什么该方法不接受丢弃。
我有一些示例代码(有一些实验被注释掉了)
<?xml version="1.0" encoding="utf-8"?>
private function get testData():ArrayCollection{
var a:ArrayCollection=new ArrayCollection;
var arr:Array=[{label:"T1"},{label:"T2"},{label:"T3"}];
a.source=arr;
return a;
}
protected function htmlSummary_dragDropHandler(event:DragEvent):void
{
if(event.dragInitiator is List){
var tree:List=event.dragInitiator as List;
var item:*=tree.selectedItem;
trace(item);
}
trace("DRAG dROP");
}
private var dragEvent:DragEvent;
protected function htmlSummary_dragEnterHandler(event:DragEvent):void
{
this.dragEvent=event;
trace("DRAG ENTER");
}
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
this.htmlSummary.htmlLoader.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,htmlSummary_nativeDragEnterHandler,true,0,true);
this.htmlSummary.htmlLoader.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,htmlSummary_nativeDragDropHandler);
}
protected function htmlSummary_dragCompleteHandler(event:DragEvent):void
{
this.dragEvent=null;
trace("DRAG COMPLETE");
}
protected function htmlSummary_dragExitHandler(event:DragEvent):void
{
this.dragEvent=null;
trace("drag exit");
}
protected function htmlSummary_nativeDragEnterHandler(event:NativeDragEvent):void
{
// if(dragEvent)
NativeDragManager.acceptDragDrop(InteractiveObject(event.currentTarget));
trace("native drag enter");
}
protected function htmlSummary_nativeDragDropHandler(event:NativeDragEvent):void
{
if(dragEvent){
var item:*;
if(dragEvent.currentTarget is List){
item=List(dragEvent.currentTarget).selectedItem;
if(item)
Alert.show(item.label);
}
}
trace("native drag drop");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:List width="130" height="100%" dataProvider="{testData}" dragEnabled="true"/>
<mx:HTML id="htmlSummary" location="http://google.com" width="100%" height="100%"
/>
<!--
nativeDragEnter="htmlSummary_nativeDragEnterHandler(event)"
nativeDragDrop="htmlSummary_nativeDragDropHandler(event)"
dragComplete="htmlSummary_dragCompleteHandler(event)"
dragDrop="htmlSummary_dragDropHandler(event)"
dragEnter="htmlSummary_dragEnterHandler(event)"
dragExit="htmlSummary_dragExitHandler(event)"
-->