Simplify keyboard focus rule to just 'widget in front', full stop.
This commit is contained in:
@@ -131,13 +131,6 @@ UInputComponent* AlxPlayerControllerBase::GetWidgetInputComponent(UUserWidget *W
|
||||
return Cast<UInputComponent>(Value);
|
||||
}
|
||||
|
||||
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)->RootCanvas->LastWidgetGrantedFocus = nullptr;
|
||||
}
|
||||
|
||||
void AlxPlayerControllerBase::AddWidgetToRoot(UUserWidget *Widget)
|
||||
{
|
||||
if (!IsValid(Widget))
|
||||
@@ -309,32 +302,20 @@ void AlxPlayerControllerBase::UpdateInputMode()
|
||||
|
||||
GameViewportClient->SetIgnoreInput(false);
|
||||
|
||||
// How we handle focus depends on whether we're showing the pointer.
|
||||
// In pointer mode, we set focus to the desired state just once,
|
||||
// and then we let the pointer control it from there on. In
|
||||
// no-pointer mode, we set focus to the desired state and
|
||||
// keep putting it back forever.
|
||||
//
|
||||
// If the user clicks the mouse on a focusable widget, the
|
||||
// viewport client notifies us of that fact. We then focus the
|
||||
// widget if possible.
|
||||
//
|
||||
if ((!ShowPointer) || (RootCanvas->LastWidgetGrantedFocus != Focus))
|
||||
// We always put keyboard focus on whatever user widget is in
|
||||
// front. If the front widget doesn't want keyboard focus,
|
||||
// then we put keyboard focus on the viewport.
|
||||
if (Focus)
|
||||
{
|
||||
if (Focus)
|
||||
if (TSharedPtr<SWidget> SlateFocus = Focus->GetCachedWidget())
|
||||
{
|
||||
if (TSharedPtr<SWidget> SlateFocus = Focus->GetCachedWidget())
|
||||
{
|
||||
SlateOperations.SetUserFocus(SlateFocus.ToSharedRef());
|
||||
RootCanvas->LastWidgetGrantedFocus = Focus;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SlateOperations.SetUserFocus(ViewportWidgetRef);
|
||||
RootCanvas->LastWidgetGrantedFocus = nullptr;
|
||||
SlateOperations.SetUserFocus(SlateFocus.ToSharedRef());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SlateOperations.SetUserFocus(ViewportWidgetRef);
|
||||
}
|
||||
}
|
||||
|
||||
void AlxPlayerControllerBase::UpdateLookAt()
|
||||
|
||||
Reference in New Issue
Block a user