Add Blueprint library func "SetFocusWidget"; improved focus setting without casting

This commit is contained in:
Steve Streeting 2021-06-04 16:50:15 +01:00
parent cb561f190a
commit 01bf2d3a40
2 changed files with 17 additions and 0 deletions

View File

@ -2,3 +2,10 @@
#include "StevesBPL.h" #include "StevesBPL.h"
#include "StevesUI/StevesUI.h"
void UStevesBPL::SetWidgetFocus(UWidget* Widget)
{
SetWidgetFocusProperly(Widget);
}

View File

@ -7,6 +7,7 @@
#include "StevesMathHelpers.h" #include "StevesMathHelpers.h"
#include "StevesBPL.generated.h" #include "StevesBPL.generated.h"
class UWidget;
/** /**
* Blueprint library exposing various things in a Blueprint-friendly way e.g. using by-value FVectors so they can * Blueprint library exposing various things in a Blueprint-friendly way e.g. using by-value FVectors so they can
* be entered directly if required, rather than const& as in C++. Also use degrees not radians. * be entered directly if required, rather than const& as in C++. Also use degrees not radians.
@ -32,5 +33,14 @@ public:
{ {
return StevesMathHelpers::SphereOverlapCone(ConeOrigin, ConeDir, FMath::DegreesToRadians(ConeAngle*0.5f), Distance, SphereCentre, SphereRadius); return StevesMathHelpers::SphereOverlapCone(ConeOrigin, ConeDir, FMath::DegreesToRadians(ConeAngle*0.5f), Distance, SphereCentre, SphereRadius);
} }
/**
* Set the focus to a given widget "properly", which means that if this is a widget derived
* from UFocusableWidget, it calls SetFocusProperly on it which allows a customised implementation.
* @param Widget The widget to give focus to
*/
UFUNCTION(BlueprintCallable, Category="StevesUEHelpers|UI")
static void SetWidgetFocus(UWidget* Widget);
}; };