ok…
With the help of the Unreal Slackers discord, i found a solution that works pretty well.
It involves some Cpp… cause not everythijg needed to do this task is exposed to Blueprint.
But i will provide my solution here.
First of all, you need to add the following into the header of a public class:
#include "Engine/DataTable.h"
#include "CommonUI/Public/CommonUITypes.h"
UENUM()
enum class EKeyHitReturn: uint8
{
KeyIsHit UMETA(DisplayName = "Is Key"),
KeyIsNotHit UMETA(DisplayName = "is Not Key")
};
[...]
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category="CommonUI|Key", meta=(ExpandEnumAsExecs="Returns"))
void GetKeyDataOfInput(ECommonInputType InputType, FDataTableRowHandle InputData, FKey InputKey, bool& bHasHoldAction, float& HoldTarget, FKey& TargetedKey, EKeyHitReturn& Returns);
And the following into the Definitions file:
void U_Your_Class_Here::GetKeyDataOfInput(const ECommonInputType InputType,const FDataTableRowHandle InputData,const FKey InputKey, bool& bHasHoldAction, float& HoldTarget, FKey& TargetedKey, EKeyHitReturn& Returns)
{
const FString ContextString;
const UDataTable* InputDataTable = InputData.DataTable.Get();
const FName RowName = InputData.RowName;
const FCommonInputActionDataBase* RowData = InputDataTable->FindRow<FCommonInputActionDataBase>(RowName, ContextString);
TargetedKey = InputKey;
if(!RowData)
{
bHasHoldAction = false;
HoldTarget = 0.0f;
Returns = EKeyHitReturn::KeyIsNotHit;
return;
}
if(RowData->GetDefaultGamepadInputTypeInfo().GetKey() == InputKey)
{
bHasHoldAction = RowData->GetDefaultGamepadInputTypeInfo().bActionRequiresHold;
HoldTarget = RowData->GetDefaultGamepadInputTypeInfo().HoldTime;
Returns = EKeyHitReturn::KeyIsHit;
return;
}
if(RowData->GetInputTypeInfo(InputType, "Generic").GetKey() == InputKey)
{
bHasHoldAction = RowData->GetInputTypeInfo(InputType, "Generic").bActionRequiresHold;
HoldTarget = RowData->GetInputTypeInfo(InputType, "Generic").HoldTime;
Returns = EKeyHitReturn::KeyIsHit;
return;
}
bHasHoldAction = false;
HoldTarget = 0.0f;
Returns = EKeyHitReturn::KeyIsNotHit;
}
I put this into a Subsystem for my UI work… But it should work if you extend a CommonUI Widget class with that, too.
Important is, that you can’t rebuild this with Blueprint, cause the Key Value of the Input DataTable of the CommonInputActionDataBase Steuct is NOT public and Blueprint exposed.
This function is need in the OnKeyDown Override of your Common Button, to check for the correct keys.
Now some screenshots of my Widget functions and Graphs.
First of all, try ro build this Graph to get the needed Events:
Next, override the OnKeyDown Function and try to rebuild that Graph:
As last step, override OnKeyUp, to enable the stopping and cancellation of the Hold functionality:
That’s it…
With that, a Triggering Input now can have Tap and Hold functionality… And you can add as many Triggers as you want to a Widget.
UpdateHoldProgress now can be used to drive a Material Parameter, ProgressBar or any other Indicator for the Hold progress you like.