1

I would like to disable copy event in the TextArea I'm using. To achieve so I added the following code block:

function initTA(){
    var tf:IUITextField = body.mx_internal::getTextField();
    tf.enabled = false;
}

<mx:TextArea id="body" creationComplete="initTA()" .../>

This is working fine unless the text area has lots of text inside in which case a scroll bar appears. After the scroll bar is being used by the user, the text area stopped blocking the copy event.

By the way, I am using text area for display purposes since I use rich text area format.

Appreciate your help Thanks! Uri

4
  • Is there any reason you can't just set <code>selectable=false</code>? (documentation) Also, in general, it's a bad practice to use <code>mx_internal</code> properties and methods - they're not really meant to be accessed publicly and their behaviour can be changed without warning. Feb 14, 2012 at 14:40
  • What do you mean it doesn't work? How can you still copy text if you can't select it? Feb 15, 2012 at 15:24
  • I think that if selectable="false" is not working then you probably have bigger problems... Feb 15, 2012 at 18:35
  • @Uri So to be clear, you want to be able to select and navigate around the text, but not give the user the option to copy it? Also, what verison of the SDK are you using?
    – Jeremy
    Feb 25, 2012 at 14:34

1 Answer 1

0

A possible solution for this issue is to disable the focus of the text-area component

function initTA(){
    var tf:IUITextField = body.mx_internal::getTextField();
    tf.enabled = false;
}

<mx:TextArea id="body" creationComplete="initTA()"  focusEnabled="false"  .../>

This way when the scroll bar is being used (due to lots of text in the text-area), the focus is not returned to the textarea and an indirect manner disables copy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.