Below is an example of forcing text input
to uppercase as the user types it. The trick is to handle the 'textInput'
event, which is dispatched after the user presses a key but before the new text
appears in the TextArea (or TextInput, or TextField). This is a cancelable
event, which means that you can call event.preventDefault() to prevent the
system from doing the default handling of this event;. For this event, calling
preventDefault() means that the TextArea won't process the keystroke. Instead
you process it yourself by uppercasing it, inserting it in the appropriate
place in the TextArea's text string, and setting the insertion point to be
after the new uppercase character. - Gordon <?xml version="1.0"
encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ private
function textInputHandler(event:TextEvent):void { event.preventDefault(); var
textArea:TextArea = TextArea(event.target); var
oldText:String = textArea.text; var
before:String = oldText.substring(0, textArea.selectionBeginIndex); var
after:String = oldText.substring(textArea.selectionEndIndex); var
newText:String = event.text.toUpperCase(); var
newInsertionOffset:int = (before + newText).length; textArea.text
= before + newText + after; textArea.setSelection(newInsertionOffset,
newInsertionOffset); } ]]> </mx:Script> <mx:TextArea
id="ti" textInput="textInputHandler(event)"/> </mx:Application> From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of brankosli I have tried -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___ |
- [flexcoders] Re: Text Area question brankosli
- RE: [flexcoders] Re: Text Area question Gordon Smith
- [flexcoders] Re: Text Area question ben.clinkinbeard
- RE: [flexcoders] Re: Text Area question Gordon Smith
- [flexcoders] Re: Text Area question brankosli
- [flexcoders] Re: Text Area question brankosli