New UILayout item: template_textbox()
Currently, a string property can only be displayed as a single line text box, and a multi-line string can only be assigned to it by python, and it won't display in the UI. But what I propose to fix that problem is adding a new UI layout item, template_textbox. For anyone not familiar with UILayout templates, they are items that take a property but display a special interface for it.
template_textbox would have these parameters:
data: Data from which to take the property
property: String property to be used. Does not need a multiline subtype option because it can already store multiline string, but not display it yet.
auto_fit: Boolean, optional. Change widget height to accomodate all lines of text
word_wrap: Boolean, optional. Enable word wrapping.
This text box would have the appearance of a UI list, but with a darker background and text can be put in it. There could also be perhaps some method of changing the color of the text for each word or character.
Edit: If word wrap was disabled, a horizontal scroll option should be added.
6 Comments
This is being worked on at projects.blender.org/blender/blender/pulls/142625
I am aware of that, the only reason I'm making a slightly different suggestion is because it lacks some features such as the auto fit option or a word wrap option that can be disabled (which in some cases would make it easier to read). Hopefully it'll be done before blender 5.1 enters beta.
Edit: The reason I was including a name change in the suggestion is because in the patch that has this feature, it is called prop_textbox, but that's not a very accurate name, because it's not a simple property button display, like float or string or vector, it's a template, which takes existing property types and makes a more complex interface for it. For example, a color property displays as a simple property button with an editable color, and it's layout item(UILayout.prop) can take a color property, but UILayout.template_color_picker also takes a color property, but creates a more complex interface for it. template_textbox would be the same, prop_textbox wouldn't be an accurate name, because it is actually a template, not a simple property display.
Would this be usable in the frame node?
What exactly do you mean by usable in the frame node? Frame nodes don't display any UI elements, so it can't be directly displayed on it. Do you mean a multiline label on a frame node?
Well, see my comment there .
That's a good idea, but considering that it would require adding UI elements to a node that doesn't use them, it might be better to add the multiline text item to the rename popup window that appears when renaming it, to keep the frame node clean and still allow for easy multiline labeling.
Edit: What I meant by keeping the frame node clean is still displaying it as a label without UI elements, because if this multiline text was added to the frame node, it would be more like a text editor window than a text display node. So it would keep it cleaner to allow for multiline text in the rename window and then display it on the frame node as multiline.