Solved

Flex TextInput

Posted on 2010-11-17
4
1,386 Views
Last Modified: 2012-05-10
How to restrict a TextInput feild from cut copy and paste?
0
Comment
Question by:srujanmiryala
  • 2
4 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34161147
So you just want to write but not cut copy and paste?

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34161153
I have not tried it but why do you try this one:

On de-focus of te component disable the text field.
try overriding the key press events for cut copy and paste for the text filed (not sure if you can override, which also check this out)

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com 
0
 
LVL 14

Accepted Solution

by:
tomaugerdotcom earned 500 total points
ID: 34164749
There are a number of options, depending on what you want to do.

If you want to use the TextInput field to display text but NOT to allow the user to edit the text, set the enabled property to false:
<s:TextInput width="175" enabled="false" text="Sample text..." />

Alternatively, if you want to prevent the user from selecting and copying the text set the selectable property to false:
<s:TextInput width="175" selectable="false" text="Sample text..." />

Finally, if you want to prevent pasting into the area, then we have to trap for the Text event. Basically you're looking to see if someone enters more than 1 letter at a time. If so, don't allow it. The reason this works is that when you're typing, each letter fires the event, but if you're pasting, the entire paste operation triggers the event and that would have more than one letter. Of course, if the person wants to paste one letter at a time, this solution will not prevent that...

private function onTextInput(event:flash.events.TextEvent):void
{
  if (event.text.length > 1)
    event.preventDefault();
}

myTextInputField.addEventListener(TextEvent.TEXT_INPUT, onTextInput);

Hope this helps!

T
0
 

Author Closing Comment

by:srujanmiryala
ID: 34164985
Hello tomaugerdotcom,

Thank you very much for the solution. I am using flex 3.0.
so for  textinput selectable property is not there.
i have went with your script code. it worked fine and that helped me a lot with the solution.

Thank you very much.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Air application in online mode and offline mode 4 416
Flex automation silktest 3 915
regular expression:- validate string of numbers 1 420
Directions for developing on IOS/iPAD 5 545
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now