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.
Field without return chars
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Field without return chars
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Field without return chars
Code: Select all
replace CR with "" in field "myfield"
Code: Select all
replace CRLF with "" in field "myfield"
Re: Field without return chars
Ok, you suggestion is to modify the string.
What is the best message to do it? During typing? Losing focus? With paste?
What is the best message to do it? During typing? Losing focus? With paste?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Field without return chars
Hi Max,
you could add a little "intelligence" to the field like this in the fields script:
That should cover all possible scenarios.
Best
Klaus
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
Best
Klaus