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
- Required SpriteMask class (ID 331) is stripped when "Strip Engine Code" is enabled
- “Maximized serialized file backup not found” error is thrown when minimizing a window in a newly opened project
- Build stack trace contains invalid lines when building with IL2CPP using scripts with delegates containing generic types in the signature
- Entities Systems window has a “Show Full Player Loop” dropdown which does nothing when clicked after enabling “Show Full Player Loop”
- Entities Hierarchy Search “Show/Hide” button’s Lens Icon is blurry when the Editor is on an external monitor
Resolution Note (fix version 2020.2):
Fixed in 2021.1.0a2
Resolution Note (fix version 2020.2):
Fixed in 2020.2.4f1