CommonUI how to get Hold progress value of custom Actions, or multiple Actions in one Widget?

Hi there…

i managed to get my gamepad support with CommonUI to work as intendet.

Now i’m facing a problem related to the Hold Actions of Common Input.

I register additional TriggerActions to (f.e.) my Inventory, to have multiple actions oer Slot possible (drop, use, move, moveAll(hold), dropAll(hold)…).

To do so, i used the Registering code from Matt > CommonUI ActionBar/Custom Actions

The problem i’m facing is, that i can register those actions to an event or a function… only returning the ActionName… which is ok to ask for contained words or such… But gives a problem when using Hold Actions, that return a hold delta float to be used in a Material for progress…for example…

How am i able to return that float of that custom actions to drive my progresses with?

1 Like

Or giving me an idea of how to add multiple Triggering Actions to one Widget?

Cause I really need:
FaceButtonBottom = use
FaceButtonLeft = Move one / Equip one
FaceButtonLeft (Hold) = Move Stack /Equip Stack
FaceButtonTop = Drop one
FaceButtonTop (Hold) = Drop Stack

And all of them for ONE Slot of the Inventory at once…

But a normal Button only gives the option for ONE triggering action…

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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.