Prevent users from pasting text into a field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Proct0r
Posts: 4
Joined: Tue May 21, 2013 11:38 am

Prevent users from pasting text into a field

Post by Proct0r » Thu May 23, 2013 12:42 pm

Hi all,

Hoping somebody will have a cunning way to prevent anything from happening when a user presses Ctr+V in a field and maybe also the right-click context menu paste too.

Guessing it will having something to do with a key press message but not sure which is the most appropriate to use, any help would be appreciated thanks!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Prevent users from pasting text into a field

Post by Klaus » Thu May 23, 2013 1:08 pm

Hi Proct0r,

you can add a "dummy" PASTEKEY handler to the field:

Code: Select all

on pastekey
   ## NADA!
   ## If you do not:-> pass pastekey
   ## then nothing will happen and that's what we want!
end pastekey
Hint:
From the dictionary about "pastekey":
...
Comments:
The LiveCode development environment traps the pasteKey message, unless "Suspend LiveCode UI" is turned on in the Development menu.
This means that the pasteKey message is not received by a stack if it's running in the development environment.
...

Best

Klaus

Proct0r
Posts: 4
Joined: Tue May 21, 2013 11:38 am

Re: Prevent users from pasting text into a field

Post by Proct0r » Fri May 24, 2013 11:39 am

Awesome, thanks for your help :)

Post Reply