Prevent Unfocus if the widget is not focused by the current user

This commit is contained in:
EmiStorrs 2024-12-04 12:46:27 -05:00
parent 75f38faa81
commit 6af2ba2766
2 changed files with 16 additions and 2 deletions

View File

@ -130,7 +130,14 @@ void UFocusableButton::Unfocus() const
LocalPlayer->GetControllerId());
if (UserIndex.IsSet())
{
FSlateApplication::Get().ClearUserFocus(UserIndex.GetValue());
TSharedPtr<SWidget> SafeWidget = GetCachedWidget();
if (SafeWidget.IsValid())
{
if (SafeWidget->HasUserFocus(UserIndex.GetValue()))
{
FSlateApplication::Get().ClearUserFocus(UserIndex.GetValue());
}
}
}
}
}

View File

@ -116,7 +116,14 @@ void UFocusableCheckBox::Unfocus() const
LocalPlayer->GetControllerId());
if (UserIndex.IsSet())
{
FSlateApplication::Get().ClearUserFocus(UserIndex.GetValue());
TSharedPtr<SWidget> SafeWidget = GetCachedWidget();
if (SafeWidget.IsValid())
{
if (SafeWidget->HasUserFocus(UserIndex.GetValue()))
{
FSlateApplication::Get().ClearUserFocus(UserIndex.GetValue());
}
}
}
}
}