UMG Button controls have an ‘OnHovered’ event that works for me, but for some reason the ‘OnHovered’ event is not consistently implemented across controls.
There are hover styles for the sliders and checkboxes, so both types of controls apparently know when the cursor is over them, but they don’t expose this.
What’s the best workaround? Can I check the active style of a control? I’ve also seen a Q&A where a frame around the control was suggested for hover detection, but that seems hacky and brittle…
The WidgetInteractionComponent has a field ‘protected: UWidgetComponent* HoveredWidgetComponent’ - it’s accessible in Blueprint just fine, but it’s protected on the C++ side.
I thought maybe checking that checking that field once per tick, but I don’t want to port my player controller to Blueprint or build some hard-to-maintain mix of Blueprint player controller derived from C++ player controller.
Is there any way I could use the blueprint bindings from C++ to read the value stored in that field?
Or could it be that the field isn’t even meant to be accessed, with the UPROPERTY() macro only slapped onto it so UE’s garbage collector can track the reference, in which case I’m still looking for another workaround
Nevermind, I scanned the headers and there’s a ‘GetHoveredWidgetComponent()’ method.
However, it’s only firing for the outermost control (i.e. if I have a Scroll Box with widget in them, GetHoveredWidgetComponent() will either return the scroll box or nullptr) and so far I couldn’t figure out how to get the child widget that’s actually under the mouse…