Nextion Wordwrapping

Hi everyone. Thanks for a great forum!!
I need some help / advise on word wrapping in a button component. I know you ca turn the isrb to true, but that cause everything in the text field to wrap at the end of the length setting. I want to wrap on WORDS. It must wrap before a new word start, not braking the WORD up and writing rest of the word on a new line, as the True setting does (after a space?). What code can I use to wrap WORDS, not just in the middel of a word ect.
I read in the Nextion forum a one liner refering to the use of /r…word padding is up to the user in user code. Nothing else, no details nothing.

Is it even possible?

I guess that it’s an one liner because it’s so popular among many programming languages (php, Java, etc.) to insert an escaped “r” to force a line break.
b0.txt=“first line\rsecond line” will then render as:

first line
second line

Thanks for your info. I understand that. My problem is I have a setup screen where the user can enter text, max length 20 char.
Then on another screen I have a button that get its text from the previous user input screen. This button is only wide enough to display 10 char per line. So I have set the button attrb isbr to True so that the text wrap to the next line. But now it wrap in the middle of words.

I want it to complete a full word and only then wrap to the next line, or wrap to the next line before starting the next word if that word cannot fit into the 1st line.

Any idea how this can be coded?

As mentioned in OP, nextion guys dont give much details. It is their “white padding for the user to code” that I dont understand and get no further info on it…

White padding means identifying blank spaces in the text and either replacing some of these by line breaks or adding spaces until the current line will be full and the next word will “fall” in the next line.
That is something which can not be done with Nextion commands. So it’s “for the user to code”, which means in your case: the setup page sends the text to the connected MCU (for example Arduino) where you process the string in your C/C++ code and then sent it back formatted to the Nextion’s button.

Thanks Fjodor!
“the setup page sends the text to the connected MCU (for example Arduino) where you process the string in your C/C++ code and then sent it back formatted to the Nextion’s button”…and you do this HOW??? :rofl: :rofl: :rofl: oh my…back to the drawing board it seems!
The send to Arduino and send back to Nextion part I can do…but the formatting in Arduino??

I would say that a string operation for locating spaces in a string and modifying them, for example using scanf(), is pretty straightforward in C/C++ and lots of code snippets and tutorials can be found on the www.

If you can’t write wrapped text to a button, I’d suggest trying with a text object on top of the button.

For the text object, the input string would also need some processing before displayed in multi line in the text object, as it would in the button caption.

Oh myyyyy…way above my paygrade as a noob hobbyist. Thanks for the pointers though. Maybe somehow I would google examples for this, but I doubt it :grinning:

Ok, but does a text object allow wrapping? If not, perhaps use more than one text object, align them on screen as needed and use your MCU to split the string as needed and then assign to one object or the other.