Improved Keyboard/Gamepad Input & Widget Focus Handling for UMG Menus

100% agree.

Brilliant! This is an excellent quick fix/hack for solving the “focused” styling problem. You inspired me to make this change in SWidget.cpp, as well, to make focus events trigger hover events.

!!!WARNING!!! I know, hacky af…but works for my use case and is what I’ll be doing until Epic finds a cleaner solution.



FReply SWidget::OnFocusReceived(const FGeometry& MyGeometry, const FFocusEvent& InFocusEvent)
{
    //-----------------------------
    // CUSTOM CODE
    FPointerEvent MouseEvent;
    OnMouseEnter(MyGeometry, MouseEvent);
    //-----------------------------

    return FReply::Unhandled();
}

void SWidget::OnFocusLost(const FFocusEvent& InFocusEvent)
{
    //-----------------------------
    // CUSTOM CODE
    FPointerEvent MouseEvent;
    OnMouseLeave(MouseEvent);
    //-----------------------------
}


I’m doing something very similar to handle navigating between menus and losing focus due to clicking outside the window.