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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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/