【问题标题】:calculateDropLocation not working计算放置位置不起作用
【发布时间】:2011-04-08 11:32:36
【问题描述】:

我有这个<s:list>,它带有一个 itemrenderer 和 arraycollection 作为数据提供者。 现在我的问题是我希望能够拖放以重新排序这些项目。

为此,我需要知道拖动的项目索引和放置位置。 我有选定的项目索引,但是当我想在我的dragcompletehandler() 中使用此代码计算我的放置位置时...

var dropLocal:DropLocation = listfiles.layout.calculateDropLocation(event);
trace (event.currentTarget.selectedIndex + "," + dropLocal.dropIndex);

它总是返回数字 3 而不是正确的放置位置索引。

这怎么可能?

【问题讨论】:

    标签: apache-flex air drag-and-drop


    【解决方案1】:

    该列表应该为您拖放。设置dragEnabled=true、dropEnabled=true 和dragMoveEnabled=true 就完成了。从列表中拖动会对其重新排序。

    如果您想手动实现拖放,您应该在 DragDrop 处理程序上执行您的工作,因为它只在有效的 DragDrop 上执行。即使没有有效的放置(当组件未标记为接受拖动时放置项目),也会触发 dragComplete 事件。

    【讨论】:

      【解决方案2】:

      calculateDropLocation 总是返回最后一行。截至 4.6 的代码不完整。

      x,y 坐标不用于事件。如果你踏入它,你会发现我做了什么。

      覆盖或调用您自己的 calculateDropLocation() 函数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-18
        • 2015-12-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-02
        • 1970-01-01
        • 2023-03-29
        • 1970-01-01
        相关资源
        最近更新 更多