[Solved] TextArea problem

BlitzMax Forums/MaxGUI Module/[Solved] TextArea problem

Nest(Posted 2015) [#1]
Hi,

I'm capturing data using a text area. I want to save this data onto a single line in a text file. The problem is, if the user presses enter to start a new line, this also makes the saved data span multiple lines too, messing up my ability to 'load' the information back at a later date.

I'm thinking of adding a unique string to the beginning of each new entry, then when I 'load' the data, continue checking subsequent lines that don't have the unique string, and adding them to my existing string.

However, is there a much simpler way of doing this? Can I convert <enter> into <space> in terms of storing the information from a textarea into a string?

Thanks for any help you can provide! :)


Nest(Posted 2015) [#2]
Is it possible to 'replace' the enters with spaces using the replace command?


Henri(Posted 2015) [#3]
Hi,

you can use Replace() to convert newline to space like:
myString:String = myString.Replace("~n", " ")

-Henri


Nest(Posted 2015) [#4]
Lovely thanks :)


skidracer(Posted 2015) [#5]
Did you consider using a TextField instead of a TextArea?


Nest(Posted 2015) [#6]
I ended up filtering out the enter/return key working when inputting data into the TextArea. It seems to work. I used the code from the manual:

Function filter(event:TEvent,context:Object)
Select event.id
Case EVENT_KEYDOWN
If event.data=13 Return 0
Case EVENT_KEYCHAR
If event.data=13 Return 0
End Select
Return 1
End Function

Then I used the SetGadgetFilter to apply the above filter function to the relevant TextAreas.


Out of interest, can TextField be displayed across multiple lines with word wrapping?