如何在Flex Text控件中禁用复制/粘贴?

时间:2022-06-04 17:28:06

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?

长话短说,我需要在我的Flex应用程序中添加一些文本,我不希望用户能够复制。我打算使用标签,但显然标签不支持文字包装。我可以这样做,以便用户无法在Flex Text控件中选择文本吗?

Thanks.

3 个解决方案

#1


6  

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

您可以使用Text控件并将selectable属性设置为false ...

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

#2


2  

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

您可以通过捕获textInput事件来禁用超过1个字符的粘贴:


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

#3


0  

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

您可以将enabled属性设置为“false”,从而禁用用户交互。您可能还想将disabledcolor属性更改为您的选择。

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

#1


6  

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

您可以使用Text控件并将selectable属性设置为false ...

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

#2


2  

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

您可以通过捕获textInput事件来禁用超过1个字符的粘贴:


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

#3


0  

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

您可以将enabled属性设置为“false”,从而禁用用户交互。您可能还想将disabledcolor属性更改为您的选择。

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