Search Issue Tracker
By Design
Votes
0
Found in [Package]
1.0.0-preview.14
Issue ID
1316122
Regression
No
[UI Toolkit] FocusEvent is never called when using RegisterCallback on UI Document rootVisualElement
How to reproduce:
1. Open the attached project's Scene labeled "SampleScene"
2. Enter the Play Mode
3. In the Game View, select a random Button
4. Select another Button
5. Inspect the Console Window
Expected result: FocusEvent is called when Button is pressed
Actual result: FocusEvent is not called
Reproducible with: 1.0.0-preview.14 (2020.2.7f1, 2021.1.0b9, 2021.2.0a3)
Couldn't test with: 2018.4.32f1, 2019.4.21f1 (UI Toolkit is not available), 2021.2.0a4, 2021.2.0a7 (Unresolvable internal package errors)
Note: Although FocusEvent is not called, FocusInEvent and FocusOutEvent are called
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
- Opening Terrain Prefab in Prefab Editing Mode throws "NullReferenceException" error
- [Search] Dragging query pills put them behind the search text field
- A CustomPropertyDrawer that returns a PropertyField for a property named the same as a child field will not render all child fields
- Graphics Settings shows default values instead of the real values in the Rendering Debugger when Volume.profile is assigned via script
- Deleting multiple Tags throws “NullReferenceException”, and "Retrieving array element that was out of bounds" errors when holding the Enter key
Resolution Note:
The FocusEvent type trickles down and does not bubble up, so you can only get it by adding a callback to the target element itself (in the provided example, the buttons); FocusInEvent and FocusDown both trickle down and bubble up, which is why the rootVisualElement gets a called for it in the provided example.
Documentation for the event types:
- https://docs.unity3d.com/ScriptReference/UIElements.FocusEvent.html
- https://docs.unity3d.com/ScriptReference/UIElements.FocusInEvent.html
- https://docs.unity3d.com/ScriptReference/UIElements.FocusOutEvent.html
For support with UI Toolkit we suggest coming to our Forum: https://forum.unity.com/forums/ui-toolkit.178/