tags:

views:

612

answers:

2

Hi I have made the following item renderer in mxml, but when I use it in a list for some reason I can not select it. Am I doing something wrong?

<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalScrollPolicy="off">
<mx:Script>
<![CDATA[
import com.pbsmedia.kanpeki.domain.calEvent.CalEventType;
[Bindable]
private var calEventType:CalEventType;
override public function set data(value:Object):void
{
if(value != null)
{
calEventType = value as CalEventType;
colorBar.setStyle("backgroundColor", calEventType.eventColor);
}
}
]]>
</mx:Script>
<mx:Image source="{calEventType.icon}" />
<mx:Label text="{calEventType.name}" selectable="true"/>
<mx:HBox height="100%" width="100%" horizontalAlign="right" paddingRight="20">
<mx:Box id="colorBar" width="50" height="100%" >
</mx:Box>

The renderer is set up on creation complete of the list's parent component as follows.

private function cc():void{
if(_itemRenderer != null)
{
lt.itemRenderer = getItemRendererFactory();
}
}
private function getItemRendererFactory():ClassFactory
{
return new ClassFactory(_itemRenderer);
}

I can't see any reason why I can't select it, any pointers much appreciated.

A: 

Instead of extending a HBox for your custom renderer, try extending ListItemRenderer directly or a Canvas.

By the way, I'll assume you've pasted it wrong on the question, since you're starting with a

<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalScrollPolicy="off">

.. and closing with:

</mx:Box>
leolobato
thanks. I had forgotten to call super.data = passed value
+1  A: 

Sorted this. I was forgetting to call super.data = value in the override.

I need to paste a post-it with this on my monitor. It gets me every time.
Kai