yarek
yarek

Reputation: 12044

flex mobile : textInput does not clear prompt on focus

a simple

<s:TextInput x="163" y="117"  prompt="hello"/>

Does not clear the prompt on focus, but clears the prompt when user first type in a letter.

This is the behaviour on flex mobile (behaviour is OK on swf )

Is that a bug and how to correct that ?

regards

Upvotes: 1

Views: 1164

Answers (3)

polloss
polloss

Reputation: 416

Actually the solution to hide prompt on focus is pretty easy, just add a style declaration like this

s|TextInput{
    showPromptWhenFocused: false;
}

or in a class

.noPromptOnFocus{
    showPromptWhenFocused: false;
}

If you use the second approach, your TextInput should look something like

<s:TextInput id="myTextInput" prompt="Write something here.." styleName="noPromptWhenFocused" />

This works fine no matter if you're using StageText or the TextInputSkin.

Upvotes: 1

Josh
Josh

Reputation: 8149

www.Flextras.com is on the right path. I had the same issues with TextInput on iPad where the field wouldn't display as a password when I needed it to.

All you need to do is manually apply the mobile TextInput skin.

<s:TextInput x="163" y="117" skinClass="spark.skins.mobile.TextInputSkin" prompt="hello"/>

You can see the answer provided to me in a separate question here.

Upvotes: 1

Arshad Ali
Arshad Ali

Reputation: 3274

There May be an-other way to get rid of that, but my approach is that you may add a focusIn event and do some thing like :

<s:TextInput id="textInput" x="10" y="24" prompt="Enter SomeThing" focusIn="textinput1_focusInHandler(event)"/>
<fx:Script>
    <![CDATA[
        protected function textinput1_focusInHandler(event:FocusEvent):void
        {
            // TODO Auto-generated method stub
            textInput.prompt = "";
        }
    ]]>
</fx:Script>

may that should work for you...

Upvotes: 2

Related Questions