开发者

Determining the state of the dropIndicator for a tree component in Flex 3

I have a custom class that extends the Tree component so I can add some logic to the drag and drop functionality and not allow folders to be dropped inside folders.

In the dragOver function, I am using:

var currNodeOver:TreeItemRenderer = TreeItemRenderer(indexToItemRenderer(calculateDropIndex(event)));

to determine the drop target, and setting:

DragManager.showFeedback(DragManager.NONE); 

accordingly.

My issue is that I can't seem to determine the state or position of the drop Indicator.

So if I have an open folder with nodes followed by another folder, and I drag a folder in between, it can go in 2 different locations: at the bottom of the open folder OR above the following folder on the root...the only indication to the user is the drop indicator, but in the dragOver 开发者_运维知识库function the dropIndex remains the same for either situation.

How do I detect between these 2 locations?


The currentTarget of the drag event should be the TreeItemRenderer or your Tree component depending on where the drag is. The DragEvent extends MouseEvent and contains the current x,y position of the mouse pointer. You can compare the mouse coordinates to the coordinates of the item renderer to see where on the item renderer the mouse is currently located. If it is in the center show feedback for dropping in the folder if it is within x pixels of the top or bottom of the renderer then show the feedback for dropping at the same level as the folder.


You should create your custom indicator, and show it with the appropriate state. check out these examples and their explanations:

  • Setting the drag indicator for Spark controls
  • Setting the drop indicator for Spark controls
  • Specifying the drag indicator by using the DragManager
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜