How To Ensure Only Plain Text Editing Is Allowed In Field

Bill Marriott wjm at wjm.org
Thu May 11 10:47:31 EDT 2006


Attaching the following script to your field should do the trick.

-- prevent line wrapping
on openField
   set the dontwrap of me to true
end openField

-- prevent newlines
on returnInField
end returnInField

on enterInField
end enterInField

-- prevent styled text
on exitField
   set the htmlText of me to me
end exitField

The first handler really isn't neeeded if you set the dontWrap via the 
properties palette or messagebox. The last handler doesn't prevent the user 
from trying to style the text, but strips the formatting once they exit the 
field.

The only way to prevent the formatting while they are editing is to check 
the keystrokes.

Bill

Ivan Wong wrote...
> Is there any easy way (beyond trapping and disabling unwanted keystrokes), 
> to
> allow users to only edit in plain text, and keep editing to a single line 
> in
> text fields. 






More information about the use-livecode mailing list