How to check if mouse cursor is over widget

is there any way to check if mouse cursor is over one of the visible widgets? OnMouseEnter and OnMouseLeave are insufficient because I do not want to iterate all widgets.

O?maybe you can use APlayerController::DeprojectMousePositionToWorld, get mouse position in world space, then raycast.

3D widget, or a screen space widget?

Screen space widget. Now I do this that way:

  • FSlateApplication::Get() - to get current instance of application
  • FSlateApplication:LocateWindowUnderMouse() - to get current window
  • get all SWidget in window
  • iterate through all widgets and check if SWidget::IsDirectlyHovered()

I do not know is it a best solution. Any better ideas?