Hey Gordon, you seem to have a knack for explaining things very clearly and concisely. Any chance we'll see tutorials or a book from you at some point? I'd buy it in a heartbeat.
Thanks, Ben --- In [email protected], "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > 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: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of brankosli > Sent: Saturday, October 14, 2006 4:14 AM > To: [email protected] > Subject: [flexcoders] Re: Text Area question > > > > I have tried > item.text = item.text.toUpperCase().and implemented on textArea > component but is seems to change all previous typing to upperCase > and that wasn't my need.I need to be able to change case when I type > new line.Maybe the other solution will help but I hope that there is > some other easier way to do that. > > If You have some idea please type it..... > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> > , "Karl Johnson" <karl.johnson@> > wrote: > > > > You probably can not turn on CAPS Lock from your flex app, > probably a > > bit of a security risk. I doubt the flash player has access and/or > > allows flash apps to get access to do that (correct me if I am > wrong). > > > > If you need to ensure that everything they type is in all CAPS, > then > > just set the text value like this: > > item.text = item.text.toUpperCase(). Or another possible way is to > > listen on the keypress and convert it as they press. I guess you > could > > also listen on the change event and convert it then, but it might > be a > > bit laggy with fast typing. > > > > Hope that helps some, feel free to reply back if you need more > help with > > it. > > > > Karl > > > > Cynergy Systems, Inc. > > > > ________________________________ > > > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> > ] On > > Behalf Of brankosli > > Sent: Friday, October 13, 2006 2:39 PM > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > Subject: [flexcoders] Text Area question > > > > > > > > I will be more that thankful if someone could solve my problem.I'm > > working with textArea component and I have 2 questions: > > > > I need to know if there is any possibility to fix left and right > margin > > in textArea component? > > And also I need to know if there is possibility to turn on and off > > capsLock by coding not by pressing keyboard? > > > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

