开发者

How can I force a tree itemrenderer to redraw during a drag and drop operation?

I have a tree control with a custom item renderer. The item renderer has different states that should be set while an item is being dragged over the item renderer. I understand from reading this post http://forums.adobe.com/message/2091088 that the 'right way' to do this is to override the 'getCurrentState' method and append some text. I do that.

Now in my tree control I handle the drag over event and get a reference to the itemrenderer that is being dragged over and I set the boolean 'dragOver' property to true. Now I just need to force my itemRenderer to redraw. I can't figure that out. A workaround, is to just set the currentState of the itemRenderer.

My question then, how can I force my itemRenderer to refresh? (and I've tried calling validateNow, invalideDisplayList/Properties/Size, to no avail)

<?xml version="1.0" encoding="utf-8"?>
<s:MXTreeItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
        <![CDATA[           
            import mx.events.DragEvent;
            import mx.events.FlexEvent;

            import spark.layouts.supportClasses.DropLocation;

            public var dragOver:Boolean = false;

            override protected function getCurrentRendererState():String
            {

                var skinState:String = super.getCurrentRendererState();

                if( dragOver )
                    skinState += "AndDragOver";

                trace('getCurrentRendererState', skinState);
                return skinState;
            }

        ]]>
    </fx:Script>

    <s:states>
        <s:State name="normal" />    开发者_如何学运维        
        <s:State name="hovered" />
        <s:State name="selected" />
        <s:State name="normalAndDragOver" stateGroups="dragOverGroup" />            
        <s:State name="hoveredAndDragOver" stateGroups="dragOverGroup" />
        <s:State name="selectedAndDragOver" stateGroups="dragOverGroup" />
    </s:states>

...


A Tree is a ListBase object, so try calling treeObject.invalidateList().

There may be a more efficient way related to the itemRenderer alone, but invalidateList() has solved all my ListBase rendering issues in the past.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜