godot
godot copied to clipboard
Add support for multiline cells to `Tree`
Confirming a change to a multiline cell is done with Ctrl+Enter instead of Enter.
My tree CSV editor

Test project: gd4-tree-multiline-items.zip

Closes godotengine/godot-proposals#3632.
Confirming a change to a multiline cell is done with Ctrl+Enter instead of Enter.
Should be the opposite.
@KoBeWi this is up to you to decide what to do
Confirming a change to a multiline cell is done with Ctrl+Enter instead of Enter.
Should be the opposite.
Fixed.
@KoBeWi this is up to you to decide what to do
@KoBeWi If you are going to rewrite Tree in the near future, then this PR can probably be closed. Just don't forget about multiline cells, please.
Needs rebase. Also the text changes should likely be reviewed by @bruvzg
I tested this and:
- ~~newline should be Shift+Enter not Ctrl+Enter (it's common in different apps, mainly chat)~~ EDIT: Ah it uses an existing action. I'd change it, but technically it's unrelated, so should be done in another PR.
- multiline cells are unusable with default settings:
The size is too small. Maybe scroll_fit_content_heightproperty is enough to fix that. Or at least docs should mention how to make the cell higher.
- multiline cells are unusable with default settings
The height of the editor is equal to the height of the line. If all cells are empty, Tree draws a line with a very small height. Perhaps this is a Tree problem? Maybe we need Tree to draw empty lines one line high?
- Maybe
scroll_fit_content_heightproperty is enough to fix that.
In this case, the editor can overflow through the line without stretching it in height. I don't think this is what we need.

The height of the editor is equal to the height of the line. If all cells are empty, Tree draws a line with a very small height. Perhaps this is a Tree problem? Maybe we need Tree to draw empty lines one line high?
Well, if the cell is editable, it's not very useful when it's tiny. Maaybe having cell edit without other cells isn't very common, but for multiline edits the height should definitely match the edited text.
In this case, the editor can overflow through the line without stretching it in height.
You could try using minimum_size_changed signal to update the cell height.
You could try using
minimum_size_changedsignal to update the cell height.
The problem is that until the change is applied, the text is only in the TextEdit, not in the Tree cell. So, the line height remains small. Changing the contents of a cell before the change is applied is wrong.
Then not sure what to do about the cell. IMO it's not fine if you have scrollable TextEdit, but then the text properly expands when you accept it. You could maybe change the cell text, but revert if it the user cancels editing text.
I made the minimum height the same size as the height of one empty line:

You could maybe change the cell text, but revert if it the user cancels editing text.
I don't think this is a good solution since editing is a lengthy process and user code can get errors if it reads the text of the cells (the value can be new before the signal, and roll back if the user undoes the changes).
Ideally, Tree should be able to draw currently edited (not yet applied) values, distinguish between visual and logical content. But now it is difficult to implement.
- newline should be Shift+Enter not Ctrl+Enter (it's common in different apps, mainly chat)
In some applications this is Shift+Enter, in others Ctrl+Enter (for example, LibreOffice Calc).
Needs a rebase, then I think it should be mergeable?
Rebased.
Thanks!
I believe this breaks set_column_clip_content, at least when using text. I'm using this method in order to display ellipsis when text overflows the column width. Is there a way to get around this that I'm not seeing?
See https://github.com/godotengine/godot/pull/76532#discussion_r1180062076. I added this to my TODO list and will try to fix it.