Page 1 of 1
dontwrap property & char without space
Posted: Mon Mar 03, 2014 6:20 am
by Jellobus
Hi everyone!
I am trying to solve an issue with characters without space in field. set dontWrap to false does not affect characters without space. look at the link first,
http://lessons.runrev.com/s/lessons/m/2 ... -wrap-text
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?
Cheers,
Louis
Re: dontwrap property & char without space
Posted: Mon Mar 03, 2014 6:34 am
by Simon
Hi Louis,
This works
Code: Select all
on closeField
put wordWrapped(me,25) into me
end closeField
put that into the field script.
It triggers when you leave the field.
Not sure you'll be happy with that but give it a try.
Write back if you want help trying a different way.
Simon
Re: dontwrap property & char without space
Posted: Mon Mar 03, 2014 11:06 am
by dave.kilroy
Hi Louis
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:
Code: Select all
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
Re: dontwrap property & char without space
Posted: Mon Mar 03, 2014 7:15 pm
by jacque
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:
Code: Select all
on cleanString
put the text of me into tString
replace cr with empty in tString
put tString into me
end cleanString
Re: dontwrap property & char without space
Posted: Mon Mar 03, 2014 7:37 pm
by dave.kilroy
Hi Jacque
Well yes - I was thinking the OP might need to use the string of chars without returns in it
And yes - "replace cr with empty" is both more elegant and faster

Re: dontwrap property & char without space
Posted: Tue Mar 04, 2014 4:01 am
by Jellobus
Hi, Simon, Dave, and Jacque.
Thanks for your advice
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.
Thanks for your creative idea!
Louis
Re: dontwrap property & char without space
Posted: Wed Mar 05, 2014 2:17 am
by Simon
Hi Louis,
This may do what you want but I'm not very happy with it.
Code: Select all
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
Re: dontwrap property & char without space
Posted: Wed Mar 05, 2014 4:05 pm
by Jellobus
Hi Simon,
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.
Cheers,
Louis