You have to keep an old copy of the text, watch for keyDown of
BACKSPACE, then fix up the text on the CHANGE event.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of khan.ibraheem
Sent: Thursday, April 24, 2008 11:27 PM
To: [email protected]
Subject: [flexcoders] Re: Newbie question: Removing text from
textarea/disabling a character

 

Thanks for your reply.

#1: Actually I wanted to disable backspace and this cannot be done
with restrict. Any other method you would like to suggest ?

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "wesley.petrowski"
<[EMAIL PROTECTED]> wrote:
>
> For #1, you can use the restrict property of TextArea. It should do 
> exactly what you need.
> 
> http://livedocs.adobe.com/flex/3/langref/mx/controls/TextArea.html#res
<http://livedocs.adobe.com/flex/3/langref/mx/controls/TextArea.html#res>

> trict
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "valdhor" <stevedepp@> wrote:
> >
> > For 1 you would probably have to add an event listener for keydown,
> > see what key it was and then stop that keycode from reaching the 
> textarea.
> > 
> > For 2, check out the following I found in the Help:
> > 
> > <?xml version="1.0"?>
> > <!-- textcontrols/TextRangeExample.mxml -->
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">
> > <mx:Script><![CDATA[
> > import mx.controls.textClasses.TextRange
> > 
> > private function resetText():void
> > {
> > textArea1.text = "This is a test of the emergency broadcast
> > system. It is only a test.";
> > }
> > 
> > public function alterText():void
> > {
> > // Create a TextRange object starting with "the" and ending 
> at
> > the 
> > // first period. Replace it with new formatted HTML text.
> > var textRange1:TextRange = new TextRange(
> > textArea1, false, textArea1.text.indexOf("the", 0),
> > textArea1.text.indexOf(".", 0)
> > );
> > textRange1.htmlText="<i>italic HTML text</i>"
> > 
> > // Create a TextRange object with the remaining text.
> > // Select the text and change its formatting.
> > var textRange2:TextRange = new TextRange(
> > textArea1, true, textArea1.text.indexOf("It", 0),
> > textArea1.text.length-1
> > );
> > textRange2.color=0xFF00FF;
> > textRange2.fontSize=18;
> > textRange2.fontStyle = "italic"; // any other value turns
> > italic off
> > textRange2.fontWeight = "bold"; // any other value turns 
> bold off
> > textArea1.setSelection(0, 0);
> > }
> > ]]></mx:Script>
> > 
> > <mx:TextArea id="textArea1" fontSize="12" fontWeight="bold"
> > width="100%" height="100">
> > <mx:text>
> > This is a test of the emergency broadcast system. It is 
> only a
> > test.
> > </mx:text>
> > </mx:TextArea>
> > <mx:HBox>
> > <mx:Button label="Alter Text" click="alterText();"/>
> > <mx:Button label="Reset" click="resetText();"/>
> > </mx:HBox>
> > </mx:Application>
> > 
> > 
> > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "khan.ibraheem" <khan.ibraheem@>
> > wrote:
> > >
> > > Hello,
> > > 
> > > I am using a textarea. I want to achieve 2 tasks:
> > > 
> > > 1) Disable a particular character i.e. let suppose I dont want to
> > > allow a certain character being shown(when it is typed) in the 
> text
> > area.
> > > 
> > > 2) How can I remove some portion of the text from the textarea. I 
> have
> > > tried slice method but it hasnt worked.
> > > 
> > > Looking for help.
> > > 
> > > Thanks.
> > >
> >
>

 

Reply via email to