Hi!
I created a TreeView with MultiColumnHeader and it works fine for showing the information that I need.
Although, my problem is with the editing / using input fields.
I have two columns, for example some key - value pairs and I want to edit the value field inside this TreeView.
I tried with multiple TextFields, like EditorGUI.TextField, EditorGUILayout.TextField or DelayedTextField, but the result was the same.
The field is there visually and I can select any line / row, but the input field not get the focus (or at least this is what I see) and not recognize any keys, in this way I’m not able to change the value of this input field.
I couldn’t find any clue what I missed or how it can work. I already checked this manual Unity - Manual: TreeView.
Here is the main part of my code for this:
Code
protected override void RowGUI(RowGUIArgs args) {
if (Event.current.rawType != EventType.Repaint)
{
return;
}
for (int i = 0; i < args.GetNumVisibleColumns(); i++) {
CellGui(args.GetCellRect(i), (Column)args.GetColumn(i), ref args);
}
}
private void CellGui(Rect cellRect, Column column, ref RowGUIArgs args) {
CenterRectUsingSingleLineHeight(ref cellRect);
Translation translation = data.translationList[args.item.id - 1];
switch (column) {
case Column.Key:
DefaultGUI.Label(cellRect, translation.key, args.selected, args.focused);
break;
case Column.Translation:
// Not get the focus when clicked on it, cannot edit the field, cannot recognize any key press, etc.
translation.translation = EditorGUI.DelayedTextField(cellRect, translation.translation);
break;
}}
Here is an example image:
Example