More work on focus, and good docs

This commit is contained in:
2026-04-22 22:52:04 -04:00
parent a964211cc8
commit a689d59ea0
11 changed files with 391 additions and 354 deletions

View File

@@ -135,7 +135,7 @@ void AlxPlayerControllerBase::RestoreFocusToFrontWidget(const UObject *Context)
{
// This will trigger UpdateInputMode to shift focus back to
// the front window, if the front window wants focus.
FromContext(Context)->LastWidgetGrantedFocus = nullptr;
FromContext(Context)->RootCanvas->LastWidgetGrantedFocus = nullptr;
}
void AlxPlayerControllerBase::AddWidgetToRoot(UUserWidget *Widget)
@@ -319,32 +319,22 @@ void AlxPlayerControllerBase::UpdateInputMode()
// viewport client notifies us of that fact. We then focus the
// widget if possible.
//
if ((!ShowPointer) || (LastWidgetGrantedFocus != Focus))
if ((!ShowPointer) || (RootCanvas->LastWidgetGrantedFocus != Focus))
{
if (Focus)
{
if (TSharedPtr<SWidget> SlateFocus = Focus->GetCachedWidget())
{
SlateOperations.SetUserFocus(SlateFocus.ToSharedRef());
LastWidgetGrantedFocus = Focus;
RootCanvas->LastWidgetGrantedFocus = Focus;
}
}
else
{
SlateOperations.SetUserFocus(ViewportWidgetRef);
LastWidgetGrantedFocus = nullptr;
RootCanvas->LastWidgetGrantedFocus = nullptr;
}
}
else if (TSharedPtr<SWidget> ClickedWidget = ClickToFocusTarget.Pin())
{
SlateOperations.SetUserFocus(ClickedWidget.ToSharedRef());
}
ClickToFocusTarget.Reset();
}
void AlxPlayerControllerBase::ClickToFocus(TSharedRef<SWidget> Widget)
{
ClickToFocusTarget = Widget.ToWeakPtr();
}
void AlxPlayerControllerBase::UpdateLookAt()