Page 1 of 1
How to declare a field only for plaintext?
Posted: Wed Jan 11, 2012 5:29 pm
by 3d-swiss
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 (24.94 KiB) Viewed 2524 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.
Re: How to declare a field only for plaintext?
Posted: Wed Jan 11, 2012 6:09 pm
by Klaus
Grüezi 3d-swiss,
are you the 3d-swiss from MTN?
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
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
Re: How to declare a field only for plaintext?
Posted: Wed Jan 11, 2012 6:24 pm
by 3d-swiss
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