放入 HBox

发布于 2024-08-02 06:13:34 字数 1434 浏览 1 评论 0原文

我有这个带有放置功能的 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 继承吗?或者这个问题还有其他解决方案吗?

谢谢!

I have this HBox with drop functionality:

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>

When the mouse enters the HBox, it works fine. The data can be dropped into the HBox and the function dragDropHandler (a very long function) does its work.

However, when the mouse hovers over the VBox, the drop functionality is lost. Can the VBox container somehow inherit from the HBox? or is there another solution to this problem?

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身骄傲 2024-08-09 06:13:34

您需要禁用 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>

You need to disable the mouseChildren property of the HBox and it should work

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文