How to create a Editable box (multiline) with characters and lines limitation?


I am trying to make a simple text box multilined where the player can write whatever he wants. That box emulates a page in a book / diary, so when the player reaches the bottom-right corner, it stops writing.

I tried with counting characters, but it does not work for what I want, because the player can enter newlines:
, and that lines don’t count as characters.

So, just want a simple editable text box, with border limitations. I don’t want vertical or horizontal scrolling, just a simple box. Thanks in advance.

You could monitor widget size (in pixels) of the Multi-line Text Box and check whether it exceeds the size of its container. If it does, you’ve run out of space. Since it’s a diary page, it will most like have a fixed size but you can also check it dynamically. Multibox should be set to Auto, it may not work well with Fill size.

You may want to work in an offset into this so you detect end of page before it happens and then decide what to do with excess text (set it to ReadOnly, add an extra page and keep on typing?)

If you are using a viewport rather than a canvas to place your diary widget, try Self->GetDesiredSize instead of GetSize.

Multiline’s native *OnTextChanged *event seems like a good place for the logic.
The whole thing is untested but should work.

Hey, first of all, thanks for the answer.

When the page is finished, I just want to stop writing. Set the box to only read its ok, but if the player wants to edit that page to erase something or whatever, he can’t.
Also, the size of the canvas slot is returning 0 :confused: Actually I don’t understand completely what that part does. I mean, I don’t know what the Slot as canvas slot is.