I have an IMGUIContainer because I need rich text support in my custom editor tool. If I click on this container once, it receives focus and then mouse hover states (e.g. hand symbol over hyperlinks) update correctly. However, if I don’t click on the element first, the hover states are not updated. I suspect this is due to my ListView under which the container is nested, grabs focus.
Do I have to force the IMGUIContainer to always have focus? If so, how do I do this when nested under a ScrollView? When I try to set .delegatesFocus on the ScrollView I receive an error “can only be set on composite roots”.
Or is there a way to update the IMGUIContainer hover states without having focus?
This might be more of a IMGUIContainer issue than a ListView issue. But I would simplify your problem temporarily by seeing if it works outside a ListView. Either way, sounds like a bug worth reporting.
For a workaround, you can try registering for MouseEnter/MouseLeave events on your IMGUIContainers. If you get them reliably, you can try calling imguiContainer.MarkDirtyLayout() (maybe schedule a repeating action via visualElement.schedule.Execute()).
1 Like
Thanks! I’ll try MarkDirtyLayout, but I’ve also reported this case: Unity Issue Tracker - SelectableLabel does not receive hover cursor when used in IMGUIContainer
Edit: After testing some more, I found that the issue may lie within IMGUI and not UI Toolkit. It appears, that even without any UI Toolkit element, when using the OnGUI method instead, my issue reproduces. I wasn’t able to make it work with any of the UI Toolkit functions (MarkDirtyLayout, MarkDirtyRepaint, Focus).