Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

REPLACE TEXT IN TEXTFIELD
Started by jjrey95 Apr 15 2019 11:21 AM

1 reply to this topic
textfield display.newtext object.text
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jjrey95

[GLOBAL: userInfoPane.html]
jjrey95
  • 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]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 834 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.


  • OlinaChang likes this


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: textfield, display.newtext, object.text