Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
I tested this script with on keyUp message in the field script, but it seems this method needs two fields. I like to make it with a single field but did not succeed..Must be there is a way to achieve. Can anyone make it with a single field?
What Simon said - plus, you might also want something to clean out those inserted 'return's from your string of chars - the following code all goes in the field's script:
on openField
cleanString
end openField
on closeField
callWrapper
end closeField
on exitField
callWrapper
end exitField
on cleanString
local tString
repeat for each char c in the text of me
if c <> return then put c after tString
end repeat
put tString into me
end cleanString
on callWrapper
local tWidth
put 25 into tWidth
put wordWrapped(the text of me,tWidth) into me
end callWrapper
Wouldn't removing the returns just unwrap it again?
At any rate, a faster way to remove the returns in a text block is to use the "replace" command. That way you don't need to loop through every character, which is slow:
I tested your script and found that spaces between words are removed if I repetitively open and close to edit text of field.
Is it possible to make field behaves like a memo app in ios? so chars will be wrapped as soon as users type it in the field.
global i
on closeField
put 0 into i
end closeField
on focusIn
put 0 into i
end focusIn
on keyDown
if the length of me > i + 10 then
put cr after me
add 10 to i
end if
pass keyDown
end keyDown
I think you are better off with the wordWrapped function.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Thanks your suggestion. I have tried like yours (slightly different) but the behavior of field was not consistent. I am keep trying to find solution to make a field behaves like typical memo app in mobile. I will post it if I find a way to achieve it.