Page 1 of 1
How do I prevent text fields from accepting formated text?
Posted: Fri Jul 12, 2013 8:01 pm
by makeshyft
Hello Livecode geniuses
How do I prevent a text field from accepting html text ... with colors and bolds and etc..... when pasting into a field? I want plain text only.
Thanks,
Re: How do I prevent text fields from accepting formated tex
Posted: Fri Jul 12, 2013 8:41 pm
by FourthWorld
See the "clipboardData" property in the dictionary.
By default the "paste" command will preserve as much of the richness of pasted content as possible, but you can make more specific choices by obtaining the clipboardData contents directly.
The clipboardData is an array, which for text contains multiple forms accessed through its keys, including "htmlText" and simply "text".
To put only the unstyled text into a field:
Code: Select all
put the clipboardData["text"] into fld "MyField"
Re: How do I prevent text fields from accepting formated tex
Posted: Fri Jul 12, 2013 8:42 pm
by makeshyft
Great....thanks Richard!
Re: How do I prevent text fields from accepting formated tex
Posted: Fri Jul 12, 2013 10:57 pm
by Klaus
Hi Tom,
sounds more like you wnat to prevent the user from PASTING styled text into a field, right?
In that case you can script a "on pastekey" (see dictionary) handler in your field, which removes the "styled" from the text
Hint:
This does NOT work in the IDE, only in the resulting standalone.
Obviously the IDE "catches" this by itself
Best
Klaus
Re: How do I prevent text fields from accepting formated tex
Posted: Sat Jul 13, 2013 12:18 am
by makeshyft
Roger that! Thanks Klaus!