mmattax
mmattax

Reputation: 27680

How can I disable copy / paste in Flex Text controls?

Long story short, I need to put some text in my Flex application and I don't want users to be able to copy. I was going to use a label, but apparently labels do not support text wrapping. Can I make it so that users cannot select text in a Flex Text control?

Thanks.

Upvotes: 3

Views: 4534

Answers (3)

bugmenot
bugmenot

Reputation: 21

You can disable paste of more than 1 character by trapping the textInput event:


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

Upvotes: 2

Brandon
Brandon

Reputation: 6872

You can set the enabled property to "false" which disables user interaction. You may want to also change the disabledcolor property to your choice.

print("
        <mx:Text enabled="false" disabledColor="0x000000" text=Text"/>
");

Upvotes: 0

Paul Mignard
Paul Mignard

Reputation: 5914

You could use the Text control and set the selectable property to false...

 <mx:Text width="175" selectable="false" text="This is an example of a multiline text string in a Text control." />

Upvotes: 6

Related Questions