How To Ensure Only Plain Text Editing Is Allowed In Field

Dar Scott dsc at swcp.com
Thu May 11 15:36:01 EDT 2006


On May 10, 2006, at 11:29 PM, 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.
>
> Currently, I can always insert linebreaks using the return key, and  
> use ctrl-b
> etc to style the text.

If you want to block the return key and block control-B, then (even  
though you were hoping to avoid this), I'd recommend blocking with  
rawKeyDown for return and controlKeyDown for control keys.  Some  
folks call keysDown() in rawKeyDown to see if the control key (key  
code 65507) is in the list of keys down, but this does not work if  
keystroke processing becomes delayed.  Simply use 'pass' if the  
keystroke is not one to be blocked.

If for some reason (say, future plans) you do not want to block this  
way you can try this:  On rawKeyDown lock the screen and send a  
message in small or zero time to a field fixing custom command  
(perhaps within your field script).  In that custom command script  
call your custom command that fixes the field and then unlock the  
screen.

(Though it does not apply to the return key or control-B, there are a  
few characters that bypass the xxxkeyDown messages, such as umlauts,  
so if you want to filter those out in the future, neither method  
above will work.  This is a known bug:  1147)

Dar Scott





More information about the use-livecode mailing list