On Oct 25, 2011, at 3:05 PM, Terry Judd wrote:

> 
> On 26/10/2011, at 05:51 AM, John Brozycki wrote:
> 
>> Hi all,
>> 
>> I have an input field that accepts URLs.  If a user copies a URL from an 
>> email or a website and pastes it, it is pasted in HTML format.  I only want 
>> the field to be plain text.  I can set the font and size, but it seems like 
>> fields always exist with (plain)text and htmltext states and LiveCode 
>> automatically accepts htmltext when it's entered.  Is there a setting to 
>> make a field ONLY plaintext, even if a user copies and pastes a URL from an 
>> email or browser?
>> 
>> My current workaround is to trap the paste function for the field, then 
>> paste and convert it, which happens instantaneously from a user standpoint:
>> 
>> on pasteKey
>>  paste
>>  set the htmltext of field "URLField" to the text of field "URLField"
>> end pasteKey
>> 
>> So, this works, but I was wondering if there is a way to limit a field to 
>> only plaintext so I wouldn't have to do this.  Any recommendations 
>> appreciated.
> 
> Much of a muchness, but you could try clearing the clipboardData["html"] 
> before you paste in your pasteKey handler. That way you should just be 
> pasting plain text.

As a fallback you can add this (untested)

on closefield
   put the text of me into me
end closefield

which would do the trick when the user leaves the field. I'm not sure but I 
think the paste operation doesn't actually trigger the engine to mark the field 
as dirty (bug?), so closefield may not be triggered, so you might have to put 
the same command into an exitfield handler. I recall scripting something 
somewhere to make sure a field is marked as dirty after a paste but I don't 
have it handy....

-- Peter

Peter M. Brigham
[email protected]
http://home.comcast.net/~pmbrig


_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to