Unfortunately, the text controls don't use events as input events, but dispatch 
them as notifications instead, so you can't fake events to them.

Most brute force way is to set text to toUpperCase on the change event.  Could 
be slow on large strings and you may have to track and restore selection.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: [email protected] [mailto:[email protected]] On Behalf 
Of per.olesen
Sent: Monday, March 09, 2009 7:03 AM
To: [email protected]
Subject: [flexcoders] Turn all keyboard input into upper-case for all TextInput 
and TextArea


I need to automatically turn all keyboard input in all TextInput and TextArea 
components in my flex application into upper-case.

It needs to function like if the user had actually typed it in upper-case. So, 
the events with the lower-case input needs to be stopped and new events with 
the upper-case equivalent need to be dispatched.

I am having trouble getting this to work, and would like some input on possible 
solutions.

Tried 1: Extending mx.controls.TextInput

And listening for TextEvent, stopping its propagation and preventing its 
default and dispatching a new TextEvent with the upper-case equivalent. But the 
upper-case char is not shown then, due to use preventing its default.

Tried 2: Listening for KeyboardEvent on stage

To catch all keyboard input and try and change it before it goes any further. 
But, some of the same problems occur. Preventing default makes the char not 
appear.

Any thought?

Reply via email to