Search Issue Tracker
Fixed in 2020.2.X
Fixed in 2020.1.X
Votes
7
Found in
2019.1
2019.2
2019.3
2019.3.0f1
2020.1
Issue ID
1206181
Regression
No
UIElements TextField is not focused and you are not able to type in characters when using Focus() method
How to reproduce:
1. Open the attached 'project-1206181.zip' project
2. In the Editor select 'Bug' > 'Bug'
3. Try to type in any characters
Expected result: the text field is focused, you are able to type in characters
Actual result: the text field is NOT focused, you are NOT able to type in characters
Reproducible with: 2019.1.0a8, 2019.1.14f1, 2019.2.17f1, 2019.3.0f4, 2020.1.0a17
Could not test with: 2019.1.0a7 and earlier (Due to script errors)
Workaround for the issue: instead of using textField.Focus() use textField.Q("unity-text-input").Focus()
Comments (4)
-
henkjan
Nov 17, 2022 12:07
Forgot to say. I've tested it in Unity 2021.3.13f1
-
henkjan
Nov 17, 2022 12:06
This doesn't work for me. Also the work-around doesn't work:
var newField = _dataLineTemplate.Instantiate();
var textField = newField.Q<TextField>("value");
textField.RegisterCallback<KeyDownEvent>(evt =>
{
if (evt.keyCode == KeyCode.Return)
AddDataItem(newField.Q<TextField>("value").value);
});
_dataFoldout.Add(newField);//Set Focus workaround: query the input within the text field
textField.Q("unity-text-input").Focus(); -
icepower2012
Sep 10, 2020 08:04
try this:
textField[0].Focus(); -
Illumina33
Mar 18, 2020 17:42
This is also occurring for us. The only workaround that has worked for me so far is to synthesize MouseDown and MouseUp events onto the field.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
Resolution Note (fix version 2020.2):
Fixed in 2021.1.0a2
Resolution Note (fix version 2020.2):
Fixed in 2020.2.4f1