Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Started by jjrey95 Apr 15 2019 11:21 AM

1 reply to this topic
textfield display.newtext object.text
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 29 posts
  • Corona SDK

Good afternoon,

I am trying to use a textfield to be able to make a description of a profile, this description must be of maximum 150 characters. Similarly when it is finished writing and enter, replace a text, the problem that I really have is that when replacing in the text (object.text = newField.text) I need the text to be distributed in three lines or so least do a "\ n" every fifty characters. But I do not know how to do it. I do not append code of this, because I do not know how to start. Thanks for any help.

[TOPIC: post.html]

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,034 posts
  • Corona SDK

You can use the standard newText to create multi-line text https://docs.coronalabs.com/api/library/display/newText.html


You can add a maximum width for the text to wrap to. As for the 150 character limit, you can add a string.len() check to the text input function, e.g. if string.len( object.text ) < 150 then, and only add new characters if that requirement is met.