flex: how to prevent PASTE (ctrl+V) in a flex3 textinput?

眉间皱痕 提交于 2019-12-12 11:42:37

问题


Hello I need to disable pasting text in a textinout (flex3) : CTRL+V Any idea ?

reagrds


回答1:


This only block pasting more than one letter, but it does work for most purposes:

<mx:TextInput textInput="if (event.text.length > 1) event.preventDefault()"/>

and for spark:

<s:TextInput
   change="if (event.operation is PasteOperation) 
   (event.target as SkinnableTextBase).text = '' "
/>



回答2:


I'm afraid you can't with the TextInput :

TextField objects do not dispatch clear, copy, cut, paste, or selectAll events. TextField objects always include Cut, Copy, Paste, Clear, and Select All commands in the context menu. You cannot remove these commands from the context menu for TextField objects. For TextField objects, selecting these commands (or their keyboard equivalents) does not generate clear, copy, cut, paste, or selectAll events. However, other classes that extend the InteractiveObject class, including components built using the Flash Text Engine (FTE), will dispatch these events in response to user actions such as keyboard shortcuts and context menus.

There is a workaround here : How do you stop Copy/Paste in a flash form



来源:https://stackoverflow.com/questions/5530397/flex-how-to-prevent-paste-ctrlv-in-a-flex3-textinput

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!