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()
-
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
- Scene is modified after exiting Play Mode when Graphics Compositor is enabled in HD RP
- Shortcuts inconsistently trigger when they have a conflict with the same Command
- On Script import/reimport MonoImporter does not generate consistent results due to updating Custom packages
- [Entities Graphics] Size of the Content Update generated folder increases when changes are made to the Scene
- In Play Mode, an extra Sync Call is made every frame when a GameObject has a Rigidbody 2D component
Resolution Note (fix version 2020.2):
Fixed in 2021.1.0a2
Resolution Note (fix version 2020.2):
Fixed in 2020.2.4f1