Try... (event.target as TextInput).text = "";
(event.target as TextInput).setFocus(); HTH Steve --- In [email protected], "gwangdesign" <gwangdes...@...> wrote: > > Hello, > > I have a TextInput, say, for user to type in to search something. After the > user presses enter Key, I want the TextInput to clear the user input text > while still staying in focus, so that the user can continue to type in other > words. > > I had a hard time to do this for a TextInput (either Gumbo or Flex 3, > although they seemingly behave differently.) > > For mx:TextInput, I am not even able to clear the user input text by handling > the "enter" event: > > private function mxTI_handleEnter(event:FlexEvent):void > { > trace("mxTI_handleEnter"); > mx.controls.TextInput(event.currentTarget).text = ""; > } > > Doesn't do anything, even though the setter for text value does get called. > Same thing for mx.controls.TextInput(event.currentTarget).htmlText= ""; > > For s:TextInput, setting text property to "" does clear the user text but I > lost caret inside the TextField in the TextInput. I have to click the > TextInput to regain focus in order to enter something. > > BTW, I am not sure if this behavior is something expected from user > experience point of view since I looked at Google, Yahoo! and Bing, all of > them did the same thing: once you pressed enter, the search textinput lost > focus. You would have to regain focus for the textinput to do another search. > > Sorry for the long text.... Hope this makes sense. Anyhow, is this something > doable? Thanks. >

