This seems to work for the Spark TextInput control (although, you're right, I 
do see that it is removing the blinking text insertion cursor - but the 
TextInput control still has focus and allows me to type):

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

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

                                                protected function 
ti_enterHandler(event:FlexEvent):void {
                                                                
arrList.addItem({lbl:ti.text});
                                                                ti.text = "";
                                                }
                                ]]>
                </fx:Script>

                <fx:Declarations>
                                <s:ArrayList id="arrList" />
                </fx:Declarations>

                <s:VGroup x="10" y="10">
                                <s:TextInput id="ti" 
enter="ti_enterHandler(event);" />
                                <mx:DataGrid id="dg" dataProvider="{arrList}" />
                </s:VGroup>

</s:Application>


Also, this seems to work for the Halo TextInput control. Not sure why, but 
adding a callLater() seems to make it happy.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>

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

                                                protected function 
ti_enterHandler(event:FlexEvent):void {
                                                                
arrColl.addItem({lbl:ti.text});
                                                                
callLater(clearTI, [ti]);
                                                }

                                                protected function 
clearTI(target:TextInput):void {
                                                                ti.text = "";
                                                }
                                ]]>
                </mx:Script>

                <mx:ArrayCollection id="arrColl" />

                <mx:VBox>
                    <mx:TextInput id="ti" enter="ti_enterHandler(event);" />
                                <mx:DataGrid id="dg" dataProvider="{arrColl}" />
                </mx:VBox>

</mx:Application>


Please feel free to file bugs for either/both issues at 
http://bugs.adobe.com/flex/.

Peter





From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of gwangdesign
Sent: Monday, June 15, 2009 1:08 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Clear user text after "enter" on TextInput (gumbo 
and/or moxie)





--- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, 
"valdhor" <valdhorli...@...> wrote:
>
> This works for me (I am using Flex 3.3 with Flash Player 9.0.159)
>
> If this is not a player or Gumbo issue, I would look at other things 
> happening after the enter event.
>
> What happens with a small test case?

Steve, Thanks for the lead.

As I found out, it seems to be the issue when I targeting Flash Player 10. The 
code:

myTextInput.text = "";
//myTextInput.setFocus();// no need to call this.

works exactly as I expect (clearing the previous text entry, with TextInput 
remaining in focus) for an mx:TextInput when compile against FP 9.

Once I target FP10, myTextInput.text = "" stops working (text not cleared out 
after "enter").

Any ideas??

Reply via email to