How to declare a field only for plaintext?

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
3d-swiss
Posts: 39
Joined: Thu Nov 06, 2008 9:11 pm

How to declare a field only for plaintext?

Post by 3d-swiss » Wed Jan 11, 2012 5:29 pm

I've create a small interface with some fields. When I user uses copy & paste from WORD or other RTF-program, then the size, color and so on, will be in the fields as well (see image).
The word "Mustermann" was written by keyboard, the word "ROT" was pasted from MS WORD.
field.png
field.png (24.94 KiB) Viewed 2520 times
How can I set a field to plaintext only?

BTW: Is there a documentation about the interface elements? I have some problems to get things the right way. Trial and error take a lot time and the results are very poor.

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

Re: How to declare a field only for plaintext?

Post by Klaus » Wed Jan 11, 2012 6:09 pm

Grüezi 3d-swiss,

are you the 3d-swiss from MTN? :D

OK, first some wonderful resources for your learning pleasure, check these stacks:
http://www.runrev.com/developers/lesson ... nferences/
Especailly my stack "Controls" might be helpful 8)

Unfortunately there is no "plain" text property for fields!

But you can do this by script with catching the "pastekey" message in your fields, put this into your fields script(s)
This message is sent when the user uses the CMD-V shortcut to paste something into a field, but will not work in the IDE
unless you choose "Suspend Developer Tools" from the "Development" menu, see also this entry in the dictionary!

Code: Select all

on pastekey

  ## First check if there IS some plain text in the clipboard!
  if the clipboarddata["text"] <> empty then

     ## Now "paste" manually...
     ## ... into the selection
     ## this way the text will get pasted where the CURSOR is currently in the field (characters selected or not!) 
     ## and is exactly what one would exspect when using CMD-V! :-)
     put the clipboarddata["text"] into the selection
  end if
end pastekey
Tested and works!

You can also mail me off-forum, if you like:
klaus AT major-k.de


Best

Klaus

3d-swiss
Posts: 39
Joined: Thu Nov 06, 2008 9:11 pm

Re: How to declare a field only for plaintext?

Post by 3d-swiss » Wed Jan 11, 2012 6:24 pm

Hello Klaus,

thanks for the quick help. I put your script into my stack script, so it will work for all fields :-)

Best regards,
Jens

Post Reply