Set Focus at TextInput Inside Spark List ItemRenderer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Set Focus at TextInput Inside Spark List ItemRenderer

ImadEddine
Please I needed Help

I Have This flex code

----------------------------------------------------------------------

<s:List id="articleDetailsList" width="100%" height="100%"
dataProvider="{currentFacture.articles}"
selectionColor="#FFFFFF" rollOverColor="gray"
horizontalScrollPolicy="off"
contentBackgroundAlpha="0" borderAlpha="0"
allowMultipleSelection="false">
<s:itemRenderer>
 <fx:Component>
  <s:ItemRenderer width="100%" click="itemClicked(event)">
   <fx:Script>
      ........
   </fx:Script>
   <s:HGroup width="100%" gap="0" paddingTop="10" paddingBottom="5"
verticalAlign="bottom">
    <s:TextInput id="articleQte" />
     ......
-----------------------------------------------------------------------

I want to set focus at articleQte like this : articleQte.setFocus() ;



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Set Focus at TextInput Inside Spark List ItemRenderer

kamcknig
This post was updated on .
If I'm understanding what you mean, you would need to control it via data.
The element of the collection you pass into the dataProvider could have a property that
indicates whether the TextInput associated with that piece of data should
have focus. Then in the script for the ItemRenderer you override the set
data method and set focus based on the data passed in. There is no good way
to access individual item renderers within an IItemRendererOwner as far as I
know, nor is it good practice to try to do so. Item renderers should be
controlled through the data they are given. So at any point that you want to change the focus you would change the property on the data object and then refresh the collection if needed (depending on the bindings in your data properties and such you might have to do that manually via ICollectionView's itemUpdated method)

Kyle



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Set Focus at TextInput Inside Spark List ItemRenderer

ImadEddine
Thanks for your reply

yes ...

When i add item to my list i needed a focus at TextInput inside itemrenderer



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Set Focus at TextInput Inside Spark List ItemRenderer

kamcknig
You'll have to do something similar to this as far as I know

https://pastebin.com/9LZbiasQ



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Set Focus at TextInput Inside Spark List ItemRenderer

kamcknig
Forgot a step

//somehwere else in your code to trigger focus on one of the text inputs'
var element = currentFacture.getElementAt(<some index>);

After that you have to set the focused property on element before updating

element.focused = true/false;





--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Set Focus at TextInput Inside Spark List ItemRenderer

ImadEddine
Thank you. I understood the idea ... it works



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/