如何在Flex中实现拖出删除?

发布于 2024-08-24 15:49:21 字数 199 浏览 6 评论 0原文

我有一个列表组件,我希望能够使用拖动和删除操作来删除项目。下降,但没有具体目标。如果您使用 Mac,我正在寻找的行为类似于 Dock 使用的行为;当您将某些内容拖出控件的边界时,它应该会出现一个图标,指示它将被删除(OSX 使用云或其他东西?),然后如果您释放它,它将从列表中删除。

我该怎么做?

(如果我需要提供更清晰的描述,请评论;我会尽力填写)

I have a List component from which I'd like to be able to remove items using drag & drop, but without having a specific target. If you use the mac, the behaviour I'm looking for is something like what the Dock uses; when you drag something out of the bounds of the control it should get an icon that indicates that it'll be deleted (OSX uses a cloud or something?) and then if you release it it will be removed from the list.

How can I do this?

(If I need to provide a more clear description, please comment; I'll fill in what I can)

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

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

发布评论

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

评论(2

心是晴朗的。 2024-08-31 15:49:21

根据我在 Flex 中拖/放的经验,您不能简单地将某些内容拖出并处理它。没有 DragOut 事件(不幸的是),因此您需要在 DragInitiator 周围的所有容器上编写 DragOver 和 DragDrop 侦听器并相应地处理该过程。

如果这些控件中的任何一个已经具有特定的dragOver 和dragDrop 事件处理程序,则这将更加耗时并且可能变得复杂。

希望这有帮助。

In my experience with drag/drop in Flex, you cannot simply drag something out and handle that. There is no dragOut event (unfortunately), so that would leave you up to the task of writing dragOver and dragDrop listeners on all the containers surrounding your dragInitiator and handling the process accordingly.

It's more time consuming and can become complicated if any of these controls already have specific dragOver and dragDrop event handlers.

Hope this helps.

意犹 2024-08-31 15:49:21

由于没有 Flex 经验,我只能提供一些伪代码,类似于我在 JavaScript 中实现类似效果的方式,但希望它能帮助您入门。

本质上,您要做的是在拖动事件期间测量您正在拖动的对象的当前坐标,以查看它们是否与原始容器相交,以及当它们超出其边界时调用逻辑来更新图标,以便表明它将被删除。然后,在放置事件中,再次检查坐标并根据需要删除该项目。

Having no Flex experience all I can offer is some psuedo code which resembles how I implemented a similar effect in JavaScript, but hopefully it will get you started.

Essentially what you'll want to do is during your drag event measure the current coordinates of the object you're dragging to see if they intersect the original container and when they fall outside of its bounds call the logic to update the icon in order to indicate it will be removed. Then, on the drop event, check the coordinates once more and delete the item if needed.

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