我有这个具有掉落功能的HBox:
SCRIPT:
// The dragEnter event handler for the HBox container enables dropping.
private function dragEnterHandler(event:DragEvent):void
{
if (!event.dragSource.hasFormat("items"))
return;
var dropTarget:Box = Box(event.currentTarget);
dropTarget.setStyle("borderStyle", "outset");
DragManager.acceptDragDrop(dropTarget);
DragManager.showFeedback(DragManager.MOVE);
}
private function dragExitHandler(event:DragEvent):void
{
if (!event.dragSource.hasFormat("items"))
return;
var dropTarget:Box = Box(event.currentTarget);
dropTarget.setStyle("borderStyle", "inset");
}
MXML
<mx:HBox id="invoiceHBox" borderStyle="inset" borderThickness="3"
height="40" width="260"
dragEnter="{dragEnterHandler(event);}"
dragExit="{dragExitHandler(event);}"
dragDrop="{dragDropHandler(event);}">
<mx:VBox>
<mx:Image source="{MailIcon32}" visible="{Boolean(invoiceEmail)}" />
<mx:Label text="{invoiceEmail.name}" styleName="heading4" />
<mx:Text text="{invoiceEmail.description}"
width="100%" selectable="false" />
</mx:VBox>
</mx:HBox>
当鼠标进入HBox时,它可以正常工作。数据可以放入HBox中,函数dragDropHandler(一个很长的函数)可以正常工作。
但是,当鼠标悬停在VBox上时,丢弃功能会丢失。 VBox容器能否以某种方式继承HBox?还是有另一个解决这个问题的方法吗?
谢谢!
答案 0 :(得分:0)
您需要禁用HBox的mouseChildren属性,它应该可以正常工作
<mx:HBox id="invoiceHBox" borderStyle="inset" borderThickness="3"
height="40" width="260"
dragEnter="{dragEnterHandler(event);}"
dragExit="{dragExitHandler(event);}"
dragDrop="{dragDropHandler(event);}"
mouseChildren="false" >
<mx:VBox>
<mx:Image source="{MailIcon32}" visible="{Boolean(invoiceEmail)}" />
<mx:Label text="{invoiceEmail.name}" styleName="heading4" />
<mx:Text text="{invoiceEmail.description}"
width="100%" selectable="false" />
</mx:VBox>
</mx:HBox>