views:

43

answers:

1

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: 

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.

Pie21
Nope... doesn't seem to work. My hunch is that the drag and drop interferes (dragEnabled, dropEnabled, dragMoveEnabled all true). There is a dropIndicator for the tree... but I need the item renderers to show their visual state. I'm going to have a look at the Adobe's jira and see if I dig up anything.
swidnikk