first thanks to dan for his answer. I tried it, and it didn't work.
However, dan's post pointed me to the right direction.
First, to place you in a better context, let me show the main mxml file (SimpleCart.mxml):
<?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"
xmlns:ctrl="controls.*"
xmlns:cart="cart.*"
minWidth="1024" minHeight="768" >
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Style source="SimpleCart.css"/>
<ctrl:NewItem id="buttonAddItem" x="9" y="15" width="394" height="27"/>
<cart:SmartShoppingCart x="8" y="47" width="378"/>
</s:Application>
I think the problem is that the component grouping the Label, TextInput and Button -called NewItem- didn't get the focus, although the TextInput control did.
So, I simply added a call to this.SetFocus, to set the focus to the NewItem component, before setting the focus to the TextInput control.
The source code for the working version of NewItem is this (look for the //Solution comments to find the changes):
<?xml version="1.0" encoding="utf-8"?>
<s:HGroup 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[
protected function newItemHandler():void
{
import cart.ItemAddedEvent;
import flash.external.ExternalInterface;
var e : ItemAddedEvent = new ItemAddedEvent( "->" + textInputItemDescription.text );
textInputItemDescription.text = "";
// *** Solution begins here
this.setFocus();
// *** Solution ends here
textInputItemDescription.setFocus();
textInputItemDescription.setSelection(0,0);
dispatchEvent( e ); // Bubble to parent = true
}
]]>
</fx:Script>
<fx:Metadata>
[Event(name="ItemAddedEvent",type="cart.ItemAddedEvent",bubbles=true)]
</fx:Metadata>
<mx:Label text="Item description:"/>
<s:TextInput id="textInputItemDescription" enter="newItemHandler() "/>
<s:Button click="newItemHandler()" label="Add to cart"/>
</s:HGroup>
Best Answer
Just a way to resolve
For Flex 4.6
Create a new skin based on TextInput component, "skin_password" or something like that:
New MXML Skin
Now, inside the skin, search for this (with some editors you can press CTRL+O, write textDisplay and press ENTER):
Add the property displayAsPassword=true:
Search for this method:
Append this line (in my case, a black dot ● instead of the default asterisk *):
Now, just set the skinClass attribute to your TextInput component (my skin example is in the package skins):
And now you have something like this: see working
-
-
A little more of explanation
When you set displayAsPassword to true, Flex add the textFlow to the RichEditableText contained in the TextInput, with the same number of "password characters".
You can see this in the code of RichEditableText.as:
In the function textContainerManager_flowOperationBeginHandler(event:FlowOperationEvent):void
You can see the passwordChar variable, it can be accessed with mx_internal