I’m trying to create a map of function pointers that I can use to execute functions with FString commands.
I am stuck with an error I don’t understand: “[C2064] term does not evaluate to a function taking 1 arguments”
I have declared the function I add to the map taking in a struct as the only argument so I don’t know why it thinks it takes more or less than 1 argument.
.H
typedef void (UUserInterfaceGadget::*FunctionPtrType)(FUserInterfaceEvent);
TMap<FString, FunctionPtrType> UserInterfaceFunctionsMap;
void InitFunctions();
void SendEvent(FUserInterfaceEvent Event);
virtual void SelectGod(FUserInterfaceEvent Event);
.CPP
void UUserInterfaceGadget::InitFunctions()
{
UserInterfaceFunctionsMap.Add("SelectGod", &UUserInterfaceGadget::SelectGod);
FUserInterfaceEvent e = FUserInterfaceEvent();
e.Name = "SelectGod";
e.Arguments.Add("Odin");
SendEvent(e);
}
void UUserInterfaceGadget::SendEvent(FUserInterfaceEvent Event)
{
this->*(UserInterfaceFunctionsMap.Find(Event.Name))(Event);
}
void UUserInterfaceGadget::SelectGod(FUserInterfaceEvent Event)
{
GEngine->AddOnScreenDebugMessage(-1, 50, FColor::Black, Name);
}