Search Issue Tracker
By Design
Votes
0
Found in [Package]
built-in
Issue ID
1410854
Regression
No
MouseLeaveEvent is not triggered when destroying target
How to reproduce:
1. Open the attached project "My project.zip"
2. Enter Play Mode
3. Click the "test" button at the top of the Game view window
4. Click the "Close" button
Expected results: Tooltip is not visible
Actual results: Tooltip is visible
Reproducible with: 1.0.0-preview.17, 1.0.0-preview.18 (2020.3.32f1), 2021.2.17f1, 2022.1.0b13, 2022.2.0a8
Could not test with: 2019.4.37f1 (UI Toolkit unavailable)
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
- Crash on "The GUID inside 'Assets/asset.png.meta' cannot be extracted by the YAML Parser." when opening the project
- Shadows disappear when looking at a certain angle in Scene view and using Cloud Shadows with Volumetric Clouds
- StackOverflowException freezes or silently crashes the Editor
- Microsoft Surface Device freezes when detaching and reattaching physical keyboard attachment to a Microsoft Surface device in Standalone Player for Windows
- Shadows are cast with artifacts on GameObjects when the light type is set to Point
Resolution Note:
This is indeed by design. No events are sent to elements that aren't part of a panel, because events are tied to panels (for example there are some differences between how editor panels and runtime panels process their events).
Also, MouseLeaveEvent isn't sent immediately when an element isn't found under the mouse. Instead, it's sent as part of a process of updating the element under the mouse, which happens through an event queue, and the DetachFromPanelEvent is processed earlier, with a higher priority.
We don't want to change the order in which events are processed unless this becomes a real generalized problem that requires a larger redesign. What we recommend is to always consider using RegisterCallback<DetachFromPanelEvent> as an additional entry point for code that react to their elements losing their hover state, or focus state, or pointer capture state, or any other on/off state that usually comes with events for both sides of the change.
It's not impossible that this could change in the future, like MonoBehaviours receiving OnDisable before they have OnDestroy called. Simplifying edge cases in the event system is a goal for the future, but it shouldn't hurt any forward-compatibility to keep a local bool to track the status and react to DetachFromPanelEvent as an additional precaution, and it will work now as well as in the future in any case.