mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 09:35:25 +00:00
Compare commits
4 Commits
2fa1f35b83
...
2ecc91f554
Author | SHA1 | Date | |
---|---|---|---|
|
2ecc91f554 | ||
|
6af2ba2766 | ||
|
5ec3dafae4 | ||
|
75f38faa81 |
@ -137,7 +137,8 @@ FPrimitiveSceneProxy* UStevesEditorVisComponent::CreateSceneProxy()
|
||||
|
||||
FBoxSphereBounds UStevesEditorVisComponent::CalcBounds(const FTransform& LocalToWorld) const
|
||||
{
|
||||
FBoxSphereBounds B = Super::CalcBounds(LocalToWorld);
|
||||
// Get superclass bounds in LOCAL space (don't pass LocalToWorld)
|
||||
FBoxSphereBounds B = Super::CalcBounds(FTransform::Identity);
|
||||
|
||||
// Now we need to merge in all components
|
||||
for (auto& L : Lines)
|
||||
|
@ -109,5 +109,35 @@ void UFocusableButton::SlateHandleHovered()
|
||||
|
||||
void UFocusableButton::SlateHandleUnhovered()
|
||||
{
|
||||
if (bLoseFocusOnUnhover)
|
||||
{
|
||||
Unfocus();
|
||||
}
|
||||
OnUnhovered.Broadcast();
|
||||
}
|
||||
|
||||
void UFocusableButton::Unfocus() const
|
||||
{
|
||||
APlayerController* OwningPlayer = GetOwningPlayer();
|
||||
if (OwningPlayer == nullptr || !OwningPlayer->IsLocalController() || OwningPlayer->Player ==
|
||||
nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ULocalPlayer* LocalPlayer = OwningPlayer->GetLocalPlayer())
|
||||
{
|
||||
TOptional<int32> UserIndex = FSlateApplication::Get().GetUserIndexForController(
|
||||
LocalPlayer->GetControllerId());
|
||||
if (UserIndex.IsSet())
|
||||
{
|
||||
TSharedPtr<SWidget> SafeWidget = GetCachedWidget();
|
||||
if (SafeWidget.IsValid())
|
||||
{
|
||||
if (SafeWidget->HasUserFocus(UserIndex.GetValue()))
|
||||
{
|
||||
FSlateApplication::Get().ClearUserFocus(UserIndex.GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,5 +95,35 @@ void UFocusableCheckBox::SlateHandleHovered()
|
||||
|
||||
void UFocusableCheckBox::SlateHandleUnhovered()
|
||||
{
|
||||
if (bLoseFocusOnUnhover)
|
||||
{
|
||||
Unfocus();
|
||||
}
|
||||
OnUnhovered.Broadcast();
|
||||
}
|
||||
|
||||
void UFocusableCheckBox::Unfocus() const
|
||||
{
|
||||
APlayerController* OwningPlayer = GetOwningPlayer();
|
||||
if (OwningPlayer == nullptr || !OwningPlayer->IsLocalController() || OwningPlayer->Player ==
|
||||
nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ULocalPlayer* LocalPlayer = OwningPlayer->GetLocalPlayer())
|
||||
{
|
||||
TOptional<int32> UserIndex = FSlateApplication::Get().GetUserIndexForController(
|
||||
LocalPlayer->GetControllerId());
|
||||
if (UserIndex.IsSet())
|
||||
{
|
||||
TSharedPtr<SWidget> SafeWidget = GetCachedWidget();
|
||||
if (SafeWidget.IsValid())
|
||||
{
|
||||
if (SafeWidget->HasUserFocus(UserIndex.GetValue()))
|
||||
{
|
||||
FSlateApplication::Get().ClearUserFocus(UserIndex.GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ public:
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
bool bTakeFocusOnHover = true;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
bool bLoseFocusOnUnhover = true;
|
||||
|
||||
// Simulate a button press
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SimulatePress();
|
||||
@ -56,6 +59,8 @@ protected:
|
||||
void SlateHandleHovered();
|
||||
void SlateHandleUnhovered();
|
||||
|
||||
void Unfocus() const;
|
||||
|
||||
virtual TSharedRef<SWidget> RebuildWidget() override;
|
||||
|
||||
|
||||
|
@ -43,6 +43,10 @@ public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
bool bTakeFocusOnHover = true;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
bool bLoseFocusOnUnhover = true;
|
||||
|
||||
protected:
|
||||
FCheckBoxStyle FocussedStyle;
|
||||
|
||||
@ -54,6 +58,8 @@ protected:
|
||||
void SlateHandleHovered();
|
||||
void SlateHandleUnhovered();
|
||||
|
||||
void Unfocus() const;
|
||||
|
||||
virtual TSharedRef<SWidget> RebuildWidget() override;
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user