Bind Enum to Control

Hello All (again).

Is it possible to bind an enumeration to one of the controls (Button, TextBox, Text)? Or do I need to write my own code to manage the binding with another variable?

Thank you.

you can build a function for this if i understand you correctly


and here’s the player controller that would call it

so if you expose a c++ enum to blueprints, you can just use the function to assign it to do whatever based on the type data value in the enum

Thank you paradoc for the explanation.

It does seem like the top graph will work. If I understand it correctly it allows the assignment of 1 enum and sets the text box based on the value of the enum. Additionally, the value is preset in the New Enum Value field of the component. Is this correct? If so, things would get a little complicated with a larger value set enumeration.

Of course I wanted to avoid any additional dependencies when possible, and was hoping that the blueprint structure could support enum type binding. For example, the below images shows two different bindings, one FText, and the other an UENUM that was converted to FText and populated in code due to the lack of support (unless I’m missing it).

A Gamertag field below is bound to an exposed variable:

And in contrast an enum for the player controller setup:

As mentioned, the source of both being exposed to the Blueprint:

Binding.Data.jpg

Again, the Controller Setup (Conventional, Southpaw) was originally a UENUM but switched to FText due to either a lack of support or my lack of understanding how to bind it. I have since written code that keeps the two variables in sync, that is the enum with the visual presentation of it, but I’d happily remove that logic if I could.

Is my understanding correct about your graph follow above?
Should I be managing the enums presentation on the display as I am?

It seems so.

ya, that’s the drawback from the provided solution, but you could always write an iterator / for-each loop that checks for a certain type if you need to find a specific value.

it’s not unusual to see huge switches for interfaces though. back in UE3, when i was using scaleform, some of the code I studied had incredibly lengthy switches in ActionScript3 and UnrealScript. i don’t know if this is common practice or not.

May be it’s a function of ActionScript/UnrealScript. In C/C++ we can create a table with function pointers and call it to perform the desired action:



enum class Action { Walk, Run, Jump, Hop, Skip, Strafe, . . . };
:
:
struct _MyActionTable
{
    Action theAction;
    void (*theFunction)(AActor&);
}
:
:
void WalkFunction( AActor& theActor )
{
    if(theActor.IsAlive())
        theActor.Walk();
}
:
:
TArray<_MyActionTable> ActionList =
{
    { Walk, &WalkFunction },
    { Run, &RunFunction },
    { Jump, &JumpFunction },
    :
};

void DoAction(Action action, AActor& actor)
{
    for(int x = 0; x < ActionList.Num(); x++)
    {
        if(action == ActionList[x].theAction)
        {
            (*ActionList[x].theFunction)( actor );
            return;
        }
    }
}


The syntax may be wrong but the concept is the same: keep a table of keys to compare against, and call the associated function when a match occurs. In addition to primitive structures like this there are classes, which allows for sleeker (and slicker) architectures. Who’s running? A horse? A camel? A man? A hovercraft?

Anyway, thank you for taking the time to explain (and confirm) the use of enum data types within blueprints. At least now I can proceed with some confidence in knowing that I’m not duplicating work that’s already been done.