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
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
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/