user3606014
user3606014

Reputation: 43

In ActionScript how to disable CTRL+V Paste in a TextArea

I disabled the Paste option in right click of TextArea using:

MyField.textField.mouseEnabled = false;

But still i can paste any text using CTRL+V is there anyway to stop it?

Upvotes: 1

Views: 434

Answers (1)

sanchez
sanchez

Reputation: 4530

You could listen for TEXT_INPUT event, and prevent default if text.length is greater then 1.

MyField.textField.addEventListener( TextEvent.TEXT_INPUT, onTextInput );

function onTextInput( e:TextEvent ):void 
{
    if( e.text.length > 1 ) 
       e.preventDefault();
}

Upvotes: 3

Related Questions