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,
How do I prevent text fields from accepting formated text?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How do I prevent text fields from accepting formated text?
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How do I prevent text fields from accepting formated tex
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:
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"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How do I prevent text fields from accepting formated tex
Great....thanks Richard!
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Re: How do I prevent text fields from accepting formated tex
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
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
Roger that! Thanks Klaus!
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com