Is it possible to limit text input in a field based upon its height?
Kay C Lan
lan.kc.macmail at gmail.com
Sun Sep 17 23:29:26 EDT 2006
Good responses for data as you type, but something else would be needed for
pasted data.
In such a case I generally force the use of monospace fonts, I can then
quickly determine exactly how many characters can fit into the field:
if (the number of chars of the clipboardData["Text"] > 543) then
put char 1 to 543 of the clipboard["Text"] into field "fixed size"
answer "Too much data"
end if
If monospace fonts are not your thing then
repeat until the formattedHeight of field "fixed size" = the height of field
"fixed size"
delete char -1 of field "fixed size"
end repeat
Obviously these scripts would need to be appropriately placed, either before
or after the actual 'paste' command in the Edit button script of the Menubar
group, along with a check that the 'focus' was on the appropriate field.
Also, these may not work for keyboard shortcuts inside the IDE, but I'm led
to believe that as a standalone they should.
HTH
More information about the use-livecode
mailing list