This content has been marked as final. Show 7 replies
editable="false" ? Of course if you want uses to be able to type in the control, but not copy/paste, that would be more difficult.
That's what I need: ability to type text but not the ability to paste text into the component. I looked at the events that get fired and did not see anything that would allow me to "catch" text being entered via a paste rather than typing.
I don't think you will be able to get to that level of granularity.
On second thought, you might be able to examine what keys are pressed, and also look at context menu selections.
You could add an event listener for a TextEvent, which will ONLY contain a field with the text being "added". If it's being typed, it'll have to be length==1. If it's being pasted it'll probably be > 1, so perhaps you could negate the change using an event handler like this. Of course, this would also disable a paste of a single character, but people don't usually paste one character anyway.
If you're able to provide this, knowing why you need to disable paste might help us suggest alternative solutions or workarounds.
Expanding on what Greg suggested, perhaps you could also:
1) Set editable = false
2) Alter the look/style so it LOOKS like the component is still enabled
3) Extend TextInput and manually listen for certain key press events, and then alter the text property appropriately
But no promises. :p I'm not sure if it can still have focus while disabled like that.
Basically, what I intend to do is create an interface that allows visitors to add content to my site (e.g. add comments to a blog). However, I want to prevent visitors from pasting advertisements for "enhancement" medications, etc. That's the basic idea of what I'm trying to accomplish.
The above suggestions will certainly give me some direction I hadn't thought of before. I just wish there as something more "built in" that I may have missed.