yarek
yarek

Reputation: 12064

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

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

reagrds

Upvotes: 4

Views: 3175

Answers (2)

Robert Bak
Robert Bak

Reputation: 4236

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 = '' "
/>

Upvotes: 5

Florian F
Florian F

Reputation: 8875

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

Upvotes: 0

Related Questions