Thanks, Brian. It gets weirder. I noticed you can access the field using .text or .value, so I wanted to know what the difference was, and if that was related to the issue. The code I used was:
void UpdateTask(KeyDownEvent e, TaskItem taskItem){
//if (e.keyCode != KeyCode.Return) return;
if (e.keyCode != KeyCode.Tab) return;
Debug.Log("Before: Details value: ***" + taskItem.TaskItemDetails.value + "***");
Debug.Log("Before: Details text: ***" + taskItem.TaskItemDetails.text + "***");
taskItem.TaskItemDetails.value = taskItem.TaskItemDetails.text.Trim();
taskItem.TaskItemDetails.value = taskItem.TaskItemDetails.text.Replace("\t","");
Debug.Log("After: Details value: ***" + taskItem.TaskItemDetails.value + "***");
Debug.Log("After: Details text: ***" + taskItem.TaskItemDetails.text + "***");
UpdateTask(taskItem);
addTaskText.Focus();
}
}
and here’s the output (when I create a new task, the default details are “blah, blah, blah”):
Before: Details value: ***blah, blah, blah***
Before: Details text: ***This is the original text.***
After: Details value: ***This is the original text.***
After: Details text: ***This is the original text.***
What’s so weird is that if I stored the .value of the field…it would be wrong - the old value. I have to use .text to get the correct text, even though the documentation says to use the value. Also, I noticed that the tab isn’t in either .text or .value…it’s just in the field. So at least the Details in the SO are correct. BTW, the TextField has the value method, while the underlying/parent TextInputBaseField has the text method, which has a protected setter.
Update: This got me curious and I checked my UpdateTask(taskItem) method, and I was using .value…and my tasks weren’t updating properly. I changed my method to use .text. This is a serious Unity bug. Folks expect value to return the full, current contents of the TextField. Guess I’ll file a bug report.
Update 2: Getting sick of this. In my UpdateTask I had a .Trim(), so I removed it since it appeared that the tab wasn’t actually there…and my SO Details now had a tab in it. So the tab IS actually there, and apparently Debug.Log strips it. Didn’t catch this previously because I was using Debug statements in the console to check whether updating worked correctly. It lied to me.