You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2013/10/19 13:08:05 UTC

Comboox clear text

I am trying to make my combobox acting as the following:
When a user enters a value that is not found in combo's data and when a
focus is moved to another control I want to clear the text that the user
just entered. Here is my code:
if (selectedIndex == -3)
{
selectedIndex = -1;
prompt = "";
}
which works fine as long as the combo has data, but if no dataProvider has
been specified that code will not clear user's entry. What would work
is textInput.text = ""; but if I go back to the combo and try to enter
another text it will not show first character I type in. Instead, the
dropdown portion will be expended and if I continue typing then the
characters starting from second one will start appearing.
Any idea?

Thanks

Re: Comboox clear text

Posted by mark goldin <ma...@gmail.com>.
That seems to do the job. A new problem (Not because of your code) I am
facing is if I type a new value in for the second time and it is the same
as it was first time the item is not removed from the input.


On Mon, Oct 21, 2013 at 10:24 AM, Kessler CTR Mark J <
mark.kessler.ctr@usmc.mil> wrote:

> Give this a shot... It should disable new values.
>
>
> <fx:Script>
>     <![CDATA[
>
>     protected function onChanging(event:IndexChangeEvent):void
>     {
>         if (event.newIndex == -3)
>         {
>             event.preventDefault();
>         }
>     }
>
>     ]]>
> </fx:Script>
>
> <s:ComboBox changing="onChanging(event);" />
>
>
> -Mark
>
> -----Original Message-----
> From: mark goldin [mailto:markzolotoy@gmail.com]
> Sent: Monday, October 21, 2013 10:31 AM
> To: users
> Subject: Re: Comboox clear text
>
> No, that does not work.
>
>
> On Mon, Oct 21, 2013 at 4:36 AM, Kessler CTR Mark J <
> mark.kessler.ctr@usmc.mil> wrote:
>
> > If your trying to prevent addition of a new item.  Try the
> > preventDefault() from the changing event.  Just check for the -3 new
> value.
> >
> > -Mark
> >
> > -----Original Message-----
> > From: mark goldin [mailto:markzolotoy@gmail.com]
> > Sent: Saturday, October 19, 2013 7:08 AM
> > To: users
> > Subject: Comboox clear text
> >
> > I am trying to make my combobox acting as the following:
> > When a user enters a value that is not found in combo's data and when a
> > focus is moved to another control I want to clear the text that the user
> > just entered. Here is my code:
> > if (selectedIndex == -3)
> > {
> > selectedIndex = -1;
> > prompt = "";
> > }
> > which works fine as long as the combo has data, but if no dataProvider
> has
> > been specified that code will not clear user's entry. What would work
> > is textInput.text = ""; but if I go back to the combo and try to enter
> > another text it will not show first character I type in. Instead, the
> > dropdown portion will be expended and if I continue typing then the
> > characters starting from second one will start appearing.
> > Any idea?
> >
> > Thanks
> >
>

RE: Comboox clear text

Posted by Kessler CTR Mark J <ma...@usmc.mil>.
Give this a shot... It should disable new values.


<fx:Script>
    <![CDATA[

    protected function onChanging(event:IndexChangeEvent):void
    {
        if (event.newIndex == -3)
        {
            event.preventDefault();
        }
    }

    ]]>
</fx:Script>

<s:ComboBox changing="onChanging(event);" />


-Mark

-----Original Message-----
From: mark goldin [mailto:markzolotoy@gmail.com] 
Sent: Monday, October 21, 2013 10:31 AM
To: users
Subject: Re: Comboox clear text

No, that does not work.


On Mon, Oct 21, 2013 at 4:36 AM, Kessler CTR Mark J <
mark.kessler.ctr@usmc.mil> wrote:

> If your trying to prevent addition of a new item.  Try the
> preventDefault() from the changing event.  Just check for the -3 new value.
>
> -Mark
>
> -----Original Message-----
> From: mark goldin [mailto:markzolotoy@gmail.com]
> Sent: Saturday, October 19, 2013 7:08 AM
> To: users
> Subject: Comboox clear text
>
> I am trying to make my combobox acting as the following:
> When a user enters a value that is not found in combo's data and when a
> focus is moved to another control I want to clear the text that the user
> just entered. Here is my code:
> if (selectedIndex == -3)
> {
> selectedIndex = -1;
> prompt = "";
> }
> which works fine as long as the combo has data, but if no dataProvider has
> been specified that code will not clear user's entry. What would work
> is textInput.text = ""; but if I go back to the combo and try to enter
> another text it will not show first character I type in. Instead, the
> dropdown portion will be expended and if I continue typing then the
> characters starting from second one will start appearing.
> Any idea?
>
> Thanks
>

Re: Comboox clear text

Posted by mark goldin <ma...@gmail.com>.
No, that does not work.


On Mon, Oct 21, 2013 at 4:36 AM, Kessler CTR Mark J <
mark.kessler.ctr@usmc.mil> wrote:

> If your trying to prevent addition of a new item.  Try the
> preventDefault() from the changing event.  Just check for the -3 new value.
>
> -Mark
>
> -----Original Message-----
> From: mark goldin [mailto:markzolotoy@gmail.com]
> Sent: Saturday, October 19, 2013 7:08 AM
> To: users
> Subject: Comboox clear text
>
> I am trying to make my combobox acting as the following:
> When a user enters a value that is not found in combo's data and when a
> focus is moved to another control I want to clear the text that the user
> just entered. Here is my code:
> if (selectedIndex == -3)
> {
> selectedIndex = -1;
> prompt = "";
> }
> which works fine as long as the combo has data, but if no dataProvider has
> been specified that code will not clear user's entry. What would work
> is textInput.text = ""; but if I go back to the combo and try to enter
> another text it will not show first character I type in. Instead, the
> dropdown portion will be expended and if I continue typing then the
> characters starting from second one will start appearing.
> Any idea?
>
> Thanks
>

RE: Comboox clear text

Posted by Kessler CTR Mark J <ma...@usmc.mil>.
If your trying to prevent addition of a new item.  Try the preventDefault() from the changing event.  Just check for the -3 new value.

-Mark

-----Original Message-----
From: mark goldin [mailto:markzolotoy@gmail.com] 
Sent: Saturday, October 19, 2013 7:08 AM
To: users
Subject: Comboox clear text

I am trying to make my combobox acting as the following:
When a user enters a value that is not found in combo's data and when a
focus is moved to another control I want to clear the text that the user
just entered. Here is my code:
if (selectedIndex == -3)
{
selectedIndex = -1;
prompt = "";
}
which works fine as long as the combo has data, but if no dataProvider has
been specified that code will not clear user's entry. What would work
is textInput.text = ""; but if I go back to the combo and try to enter
another text it will not show first character I type in. Instead, the
dropdown portion will be expended and if I continue typing then the
characters starting from second one will start appearing.
Any idea?

Thanks