Page 1 of 1
Field without return chars
Posted: Tue Mar 18, 2014 1:37 pm
by MaxV
Hi all,
I created a single line field. When I pasted some text in it, I didn't realize that I pasted more than one line. This led to several bugs...
What is the best practice to obtain a really one line field? I mean a field that can't contain more than one line.
Re: Field without return chars
Posted: Tue Mar 18, 2014 1:43 pm
by bangkok
Code: Select all
replace CR with "" in field "myfield"
You might be confronted with other issues (for instance if your field contains text coming from various plateforms). In this case you could add :
Code: Select all
replace CRLF with "" in field "myfield"
Re: Field without return chars
Posted: Wed Mar 19, 2014 12:35 pm
by MaxV
Ok, you suggestion is to modify the string.
What is the best message to do it? During typing? Losing focus? With paste?
Re: Field without return chars
Posted: Wed Mar 19, 2014 1:07 pm
by Klaus
Hi Max,
you could add a little "intelligence" to the field like this in the fields script:
Code: Select all
## Prevent any new line characters in field:
on returninfield
##
end returninfield
## Same here:
on enterinfield
##
end enterinfield
## "Trap" the PASTEKEY
## Hint, this does not work in the IDE out of the box, please read the dictionary about "Pastekey"!
on pasteKey -- replace returns with spaces before pasting
if the clipboardData["text"] <> empty then
set the clipboardData["text"] to replaceText(the clipboardData["text"],return,space)
paste
end if
end pastekey
That should cover all possible scenarios.
Best
Klaus