I have a List which has TextInput as itemRenderers for all its items. Upon application launch the items are rendered in the TextInputs correctly. The data is being populated from an Array of Objects.
What I want is, after the data has been populated in the ItemRenderers, I want to have an additional item renderer (TextInput of course)...so that if the user wants to enter another item, he can put it in the additional textInput.
And I also want to add the additional itemRenderer each time the user has added a new item and taps ENTER on the newly added item.
Below is my itemRenderer, there is the clearTxt_enterHandler handler..but I wonder how to add another itemRenderer upon "Enter".
Can somebody guide me with this?
Thx
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true" xmlns:components="components.*" width="100%">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Script>http://stackoverflow.com/questions/4199373/flex-4-is-a-good-practice-store-the-loaded-bitmapdata-in-a-value-object-and-then
<![CDATA[
import mx.events.FlexEvent;
import skins.ClearableTextInputSkin;
override public function set data( value:Object ) : void {
super.data = value;
//clearTxt.text = value.label;
}
protected function clearTxt_enterHandler(event:FlexEvent):void
{
trace("On Enter");
}
]]>
</fx:Script>
<components:ClearableTextInput text="{data.label}" id="clearTxt"
skinClass="skins.ClearableTextInputSkin" enter="clearTxt_enterHandler(event)" left="10" top="36" width="220" />
</s:ItemRenderer>
And this is my list that comes from the main application:
<s:List id="myList" itemRenderer="renderers.TextInputRenderer" dataProvider="{xxx}" width="100%">
<s:layout>
<s:TileLayout requestedRowCount="2"columnAlign="justifyUsingWidth"/>
</s:layout>
</s:List>