How to wrap the textEdit node to a new row and column when overflowing
Asked Answered
M

5

0

I have a label and a textEdit element inside an HBoxContainer. I want to wrap the textEdit, when overflowing, to the same column as the label while being inline with the same label.


Unwanted result


Desired result

Merimerida answered 6/3 at 21:51 Comment(0)
L
1

Not possible with TextEdit. You would have to develop your own version of TextEdit based on a Control node and handle all the input and drawing of the text and the cursor via CanvasItem methods. That sounds like a major undertaking, even if you don't need full feature parity with the original TextEdit.

Latoshalatouche answered 6/3 at 22:52 Comment(0)
M
0

Latoshalatouche I see. Thanks for the support.

Merimerida answered 6/3 at 23:20 Comment(0)
T
1

A workaround is to add the label text as the beginning content of the TextEdit. You could use the TextEdit's signals, such as text_changed, to prevent that content from being changed or deleted.

Taite answered 6/3 at 23:42 Comment(0)
M
0

Taite I already thought on doing something like this, but I give up 'cause I wouldn't be able to customize the label individualy. But I also didn't know about these TextEdit's signals, I'll give it a try and see how it looks.

Thanks for the support.

Merimerida answered 7/3 at 2:43 Comment(0)
L
0

Taite That is an interesting approach. Maybe my initial assessment was incorrect.

But using just the signals is probably not enough. You would have to override the _backspace, _past, _past_primary_clipboard and _handle_unicode_input functions. With all these functions you would check if the caret is inside the label and if not, you would call the function of the parent class.
The only signal that is actually useful in this context would be caret_changed. You would use this signal to avoid moving the caret onto the label by moving the caret back to a valid position.
Not sure how text selections are handled. That might be a problem, if this feature is enabled.

Latoshalatouche answered 7/3 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.